Recent Posts

Pages: [1] 2 3 ... 10
1
Support / MIT App Inventor 2 has BLE extension
« Last post by jterry on August 15, 2017, 02:57:37 PM »
I tried using the MIT App Inventor 2, the BLE isn't officially released yet, but they let you download the beta extension to tinker around with.  I couldn't get it to see the Simblee, has anyone else tried it?

Thanks
JT
 
2
Simblee For Mobile / Re: SimbleeForMobile two screens
« Last post by Michael Anderson on August 15, 2017, 08:11:52 AM »
Hi Tolson,

Thank you for the reminding. I made a mistake that I copied wrong codes here. I have deleted the wrong ones. The problem is that, when changing to screen 2 from screen 1, the random number still displays.

Hey Stanley,
Sounds like you are looking for the function call
SimbleeForMobile.setVisible(text1,false);

In this case anytime you call draw for screen 2, you should setVisiblilty for your random number text object ID to false.
Not sure if you need to set it back to true when you draw screen 1 again, I assume the existing draw call for it will make it visible again.

I looked up this function because I did not like to stare at a white blank screen as my Simblee App spent 3-5 seconds downloading my logo image when the app is first opened up, So when screen 1 is created I do this

  int textID = SimbleeForMobile.drawText(1, 1, "Downloading Content, Please wait...", BLACK, 20);
  SimbleeForMobile.imageSource(IMAGE_1, PNG, image4535_png, image4535_png_len);
  SimbleeForMobile.drawImage(IMAGE_1, 10, 7);
  SimbleeForMobile.setVisible(textID,false);

So a downloading message appears on the screen immediately, then after the image is transferred from the Simblee device to the App (depending on size of image could take some time) the message quickly hides itself.
3
Simblee For Mobile / Re: SimbleeForMobile two screens
« Last post by Stanley on August 14, 2017, 07:28:38 PM »
Hi Tolson,

Thank you for the reminding. I made a mistake that I copied wrong codes here. I have deleted the wrong ones. The problem is that, when changing to screen 2 from screen 1, the random number still displays.
4
Simblee For Mobile / Re: SimbleeForMobile two screens
« Last post by tolson on August 14, 2017, 07:07:02 PM »
Hi Stanley,

I edited your post for you so it is better readable.

You can/should wrap your sketch between CODE flags.

As far as your code generating the image on both screens... Looks like that is what your code is saying to do. You define, initialize, and drawImage in both createScreen1 and createScreen2.
5
Simblee For Mobile / Re: SimbleeForMobile two screens
« Last post by Stanley on August 14, 2017, 06:21:59 PM »
Hi Nelson,

The following is my sketch codes. Thank you for the help.


Code: [Select]

#include <SimbleeForMobile.h>

#include "heart6_png.h"

//
// The ID of the button which displays screen 2
//
int toScreen2ButtonID;

//
// The ID of the button which displays screen 1
//
int toScreen1ButtonID;

//
// The ID of the current screen being displayed
//
int currentScreen;

/*
 * Traditional Arduino setup routine
 *
 * Initialize the SimbleeForMobile environment.
 */
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Setup beginning");
 
  SimbleeForMobile.deviceName = "2 Screens";
  SimbleeForMobile.advertisementData = "Sample";

  // use a shared cache
  SimbleeForMobile.domain = "twoscreens.simblee.com";
 
  // Begin Simble UI
  SimbleeForMobile.begin();
     randomSeed(analogRead(0));
  Serial.println("Setup completed");
}
uint8_t text1;
/*
 * The traditional Arduino loop method
 *
 * Enable SimbleeForMobile functionality by calling the process method
 * each time through the loop. This method must be called regularly for
 * functionality to work.
 */

unsigned long lastUpdated = 0;
unsigned long updateRate = 500; // half a second
void loop() {
 unsigned long loopTime = millis();

   if (SimbleeForMobile.updatable && updateRate < (loopTime - lastUpdated))
  {
    lastUpdated = loopTime;
     int hr = random(60,80);
          char buf1[16];
    sprintf(buf1, "%d", hr);
           SimbleeForMobile.updateText(text1, buf1);
  // put your main code here, to run repeatedly:
  // process must be called in the loop for Simblee UI
  }
  SimbleeForMobile.process(); 
 
}

/*
 * Callback when a Central connects to this device
 *
 * Reset the current screen to non being displayed
 */
void SimbleeForMobile_onConnect()
{
  currentScreen = -1;
}

/*
 * Callback when a Central disconnects from this device
 *
 * Not used in this sketch. Could clean up any resources
 * no longer required.
 */
void SimbleeForMobile_onDisconnect()
{
}

/*
 * SimbleeForMobile ui callback requesting the user interface
 *
 * Check which screen is being requested.
 * If that is the current screen, simply return.
 * If it is a different screen, create the requested screen.
 * A screen request which is out of range, is logged and ignored.
 */
void ui()

  if(SimbleeForMobile.screen == currentScreen) return;
 
  currentScreen = SimbleeForMobile.screen;
  switch(SimbleeForMobile.screen)
  {
    case 1:
      createScreen1();
      break;
       
    case 2:
      createScreen2();
      break;
           
   default:
      Serial.print("ui: Uknown screen requested: ");
      Serial.println(SimbleeForMobile.screen);
  }
}

/*
 * SimbleeForMobile event callback method     
 *
 * An event we've registered for has occur. Process the event.
 * The only events of interest are EVENT_RELEASE which signify a button press.
 * If the button to open the screen not being displayed is pressed, request
 * to show that screen.
 */
void ui_event(event_t &event)
{
//  printEvent(event);
  if(event.id == toScreen1ButtonID && event.type == EVENT_RELEASE && currentScreen == 2)
  {
    SimbleeForMobile.showScreen(1);
  } else if(event.id == toScreen2ButtonID && event.type == EVENT_RELEASE && currentScreen == 1)
  {
    SimbleeForMobile.showScreen(2);
  }
}

/*
 * Create the first screen.
 *
 * The screen simply consists of a label displaying the screen number
 * and a button which swaps screens. Register for events on the button
 * such that we receive notifications when it is pressed.
 */
void createScreen1()
{
    #define  IMAGE2  5
  //
  // Portrait mode is the default, so that isn't required
  // here, but shown for completeness. LANDSCAPE could be
  // used for that orientation.
  //
  SimbleeForMobile.beginScreen(YELLOW, PORTRAIT);
     text1 = SimbleeForMobile.drawText(210, 150, "", BLUE, 45);
    SimbleeForMobile.imageSource(IMAGE2, PNG,  heart6_png, heart6_png_len); 
  SimbleeForMobile.drawImage(IMAGE2,110,100);
      if(SimbleeForMobile.remoteDeviceType == REMOTE_DEVICE_OS_IOS) {
    SimbleeForMobile.drawText(260, 175,  "BPM", BLUE, 20);
    //230,325
  } else if(SimbleeForMobile.remoteDeviceType == REMOTE_DEVICE_OS_ANDROID) {
    SimbleeForMobile.drawText(270, 248, "\xc2\xb0" "C", BLUE);
  } else if(SimbleeForMobile.remoteDeviceType == REMOTE_DEVICE_OS_UNKNOWN) {
    SimbleeForMobile.drawText(270, 248, "C", BLUE);
  }

  int textID = SimbleeForMobile.drawText(80, 60, "Screen 1", BLACK, 40);
  toScreen2ButtonID = SimbleeForMobile.drawButton(100, 200, 100, "Screen 2");

  //
  // Receive notifications when a "release" occurs on the button.
  // Other event notifications are supported and can be combined in this call.
  // I.e. to receive press and release events you'd pass:
  //
  // EVENT_PRESS | EVENT_RELEASE
  //
  // into the function:
  //
  // SimbleeForMobile.setEvents(toScreen2ButtonID, EVENT_PRESS | EVENT_RELEASE);
  //
  // However, you don't want to register for events which are not required as
  // that results in extra traffic.
  //
  SimbleeForMobile.setEvents(toScreen2ButtonID, EVENT_RELEASE);
  SimbleeForMobile.endScreen();
}

/*
 * Create the second screen.
 *
 * The screen simply consists of a label displaying the screen number
 * and a button which swaps screens. Register for events on the button
 * such that we receive notifications when it is pressed.
 */
void createScreen2()
{
   
  SimbleeForMobile.beginScreen(WHITE);
 

  int textID = SimbleeForMobile.drawText(80, 60, "Screen 2", BLACK, 40);
  toScreen1ButtonID = SimbleeForMobile.drawButton(100, 200, 100, "Screen 1");

   
  SimbleeForMobile.setEvents(toScreen1ButtonID, EVENT_RELEASE);
  SimbleeForMobile.endScreen();
}

/*
 * Utility method to print information regarding the given event
 */
void printEvent(event_t &event)
{
  Serial.println("Event:");
  Serial.print("  ID: ");
  Serial.println(event.id);
 
  Serial.print("   Type: ");
  Serial.println(event.type); 

  Serial.print("   Value: ");
  Serial.println(event.value);
 
  Serial.print("   Text: ");
  Serial.println(event.text); 
 
  Serial.print("   Coords: ");
  Serial.print(event.x); 
  Serial.print(","); 
  Serial.println(event.y); 
}


6
Simblee For Mobile / Re: SimbleeForMobile two screens
« Last post by RFD_Nelson on August 14, 2017, 06:38:35 AM »
Hi Stanley,

In order to help you further, can you please attach a copy of your sketch?

Thanks,

Nelson
7
Simblee For Mobile / SimbleeForMobile two screens
« Last post by Stanley on August 13, 2017, 11:36:17 PM »
Hi all,

I am now studying how to use SimbleeForMobile to have two screens on my mobile app. For now, I only added one picture and one function that can generate random number on Screen 1. However, when I tried to change to Screen 2, the picture and number are still there. I wonder if I need a function to clear the previous stuff before running the codes for Screen 2.

Appreciate if someone could help me. Thanks in advance.
8
Support / Switch Case vs IF's
« Last post by Wayne on August 09, 2017, 01:30:24 PM »
With the help of Patty, Aaron and all here, Thanks.. I have basically finish the Wireless Foot Switch 1st phase with demo boards and software.

Using the Simblee under SimbleeCOM, I have pairing, Pulse, Battery tests, and even WDT on the receiver side.

Now to the question.. I'm trying not to have lots of stuff like LED's on or having a Solid State Relay active via the loop function.  Like in the IF statement, if some == this, do a HIGH..

So I have create the switch case whereas case 51  if passthru == 0, void to turn on led and pasthru =1.
I do a timeout if I loose BT signal or an end of action sent via the Foot Switch as endsend which is 69.

I was thinking that once the case 51 and passthru == 0, it will skip and the void will still have the led on.  When either BT dies via a loss of BT or the case 69 recvd, I drop all stuff
via another void.

If it was under the if statements, it will have lots of workings going on in which in my thinking, slows the loop down somewhat.

I was hoping the speed of this will keep the SSR's on when required with lets say, no flicker.. Unlike a regular relay that is slower in reaction..
But as the systems go, they use micro switches originally which can jitter.  So maybe I'm safe..

Educated guess is I'm fine without having a tiny bit of chatter..
9
Knowing that it is just turning GPIO 31 on and off you can just use the Arduino way of doing that.

pinMode(31, OUTPUT);

digitalWrite(31, HIGH);
or
digitalWrite(31, LOW);
10
For some reason, we can find "SimbleeBLE.txPowerLevel" in the libraries.
But we cannot find
SimbleeBLE.proximityMode(FALSE);
So, that is curious.

We are in contact with RFDigital, as in they want more info.
Will update as soon as we have new info.

Pages: [1] 2 3 ... 10