Author Topic: Display More Than 7 Images  (Read 1015 times)

rickpres22

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Display More Than 7 Images
« on: December 08, 2016, 11:05:19 AM »
I am having an issue when trying to display more than 7 images on a multi-screen app.  The app works great when I display 7 images.  If I try to display 8 the images will load just fine the first time the sketch is downloaded, the app runs, and the screen is created.  After I leave the 8 image screen and then try to come back to it the app crashes on my phone.  Trying to re-connect afterwards crashes the app.  If I include the SimbleeForMobile.baseline command (so the images are pulled from the phone's cache instead of re-transferred from the Simblee), don't update the baseline time, and download the sketch the app crashes on my phone the first time the 8 image screen is created.

Size of the images does not seem to be an issue but the number.  I've narrowed it down to being able to define images 1-7 but not >7.  The "Getting Started with SimbleeForMobile" documents (pg5) state I should be able to use images 1-31.  In the attached code I'm only defining one image but if I define it higher than 7 the same results occur.  Anyone know whats going on here or it there is a parameter somewhere I am missing?  Am I just limited to 7 images?

Code: [Select]
#include <SimbleeForMobile.h>
#include "UpButtonPress.h"

#define ImgUpButPress 7  //changeing this value to greater than 7 crashes app

uint8_t image1;
uint8_t image2;
uint8_t buttonGoScreen1;
uint8_t buttonGoScreen2;
int currentScreen;

void setup() {
  // Simblee Info
  SimbleeForMobile.deviceName = "SUB";
  SimbleeForMobile.advertisementData = "332017-100";
  // Begin Simblee UI
  SimbleeForMobile.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
  // process must be called in the loop for Simblee UI
  SimbleeForMobile.process(); 
}

void SimbleeForMobile_onConnect(){
  currentScreen = -1;
}

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);
  }
}

void createScreen1()
{
  SimbleeForMobile.beginScreen(WHITE, PORTRAIT);
  SimbleeForMobile.drawRect(0, 0, 320, 570, rgb(255,255,255), rgb(175,175,175));

  image1 = SimbleeForMobile.drawImage(ImgUpButPress, 200, 115);
  image2 = SimbleeForMobile.drawImage(ImgUpButPress, 200, 162);
  buttonGoScreen2 = SimbleeForMobile.drawButton(200, 300, 100, "Screen2", rgb(52,69,79), 0);

  SimbleeForMobile.imageSource(ImgUpButPress, PNG, UpButtonPress_png, UpButtonPress_png_len);
  SimbleeForMobile.setEvents(buttonGoScreen2, EVENT_RELEASE);
 
  SimbleeForMobile.endScreen();
}

void createScreen2()
{
  SimbleeForMobile.beginScreen(WHITE, PORTRAIT);
  SimbleeForMobile.drawRect(0, 0, 320, 570, rgb(255,255,255), rgb(175,175,175));

  buttonGoScreen1 = SimbleeForMobile.drawButton(200, 300, 100, "Screen1", rgb(52,69,79), 0);

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



/*
 * SimbleeForMobile event callback method
 */
void ui_event(event_t &event)
{
  switch (currentScreen)
  {
    case 1:
      handleScreen1Events(event);
      break;
    case 2:
      handleScreen2Events(event);
      break;
  }
}

void handleScreen1Events(event_t &event) { 
  if (event.id == buttonGoScreen2 && event.type == EVENT_RELEASE) {
    SimbleeForMobile.showScreen(2);
  }
}

void handleScreen2Events(event_t &event) { 
  if (event.id == buttonGoScreen1 && event.type == EVENT_RELEASE) {
    SimbleeForMobile.showScreen(1);
  }
}

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Display More Than 7 Images
« Reply #1 on: December 08, 2016, 03:47:39 PM »
I don't know. Should you define the imageSource prior to defining the ImageIDs?
Although, their example SimbleeUITest doesn't. Might be worth a try to see if it matters.
« Last Edit: December 08, 2016, 03:55:06 PM by tolson »

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Display More Than 7 Images
« Reply #2 on: December 08, 2016, 04:31:19 PM »
OK, trying to duplicate your experience, I loaded the SimbleeUITest example.
I changed their DOT images from 1 2 3 to like so...
Code: [Select]
// Image numbers
//
#define YELLOW_DOT_IMAGE 10
#define RED_DOT_IMAGE 12
#define GREEN_DOT_IMAGE 8

It compiled and worked on Android 5 every time.

On Android 6.x it worked the first time. Then coughs up "Unfortunately, For Mobile has Stopped.... REPORT... OK
Repeatedly.
Note. The APP starts up OK. And when choosing the "Test various image APIs" it start to display and then chokes back to the SimbleeForMobile chooser screen.

Interestingly, when I go back to connecting with Android 5 it then chokes exactly the same way. So I suspected whatever broke, it might require the Simblee itself to be reset or restarted... Nope, after a reset still chokes. And after a power off/on still chokes. So seems like whatever broke has hosed the APP in the smart devices. Maybe.

Oddly enough, re-uploading the sketch got the sketch working again on the Android 5. ONCE.

On the iOS the sketch works the first time; but, going  back to the home screen and then back to the images test crashes the APP itself. Where as in the Android it drops back to the SimbleeForMobile chooser.

Hopefully, the RF digital team is monitoring these issues.




« Last Edit: December 08, 2016, 04:33:17 PM by tolson »

rickpres22

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Display More Than 7 Images
« Reply #3 on: December 09, 2016, 09:05:31 AM »
Yes your experiences sound consistent with mine.  I believe everything works when the images are transferred from the Simblee to the device for the first time.  I believe when a screen is re-created or when the Simblee re-connects the images are loaded from the cache on the phone.  This is where the problem is if there are more the 7 images.  Sounds like this is true for both iOS 10.0.2 and Android 6.x. 

I will update to the latest iOS and see if the issue persists there.  Is the Simblee firmware updatabe or do they roll out new chips with any firmware updates?

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Display More Than 7 Images
« Reply #4 on: December 09, 2016, 10:20:36 AM »
I can't say it is because of more than 7 images being cached. It might be simply the ID number being bigger than 7. How can we tell how many images are actually cached in the phones? And how to force a clear the cache? On my Android settings there is a "Clear Cache" which clears cache for all apps. Afterwards, the APP still choked with "Unfortunately, For Mobile has stopped".

As far as firmware in the SOC... RFDigital has to chime in on that. So far, they have not provided a way to update the RFduino firmware and might not on the Simblee. A LOT of people would be happy if they did.

But, they do update the Arduino Library and the SimbleeForMobile phone APP from time to time.