Switch screen (save data of my switch)

i have my switch on in screen1 and when i open screen2 and back to the screen1 where i have my switch on the switch turns off. what will i do?

Two options:

  • Stay in one Screen, and use stacked Vertical Arrangements instead of Screens, only one visible at a time
  • Remember your switch status in TinyDB, and use the two events (Screen.Initialize and When Other Screen Closed) to restore the switch status from TinyDB.

how will i do the second option? using intialize and close other screen? and i'm using firebase.


I mentioned TinyDB because it is local, and returns immediate results.

Firebase would require initiating a read of the SENSORS key and adding event blocks to intercept the incoming SENSORS value and adjust the display.

These are the blocks where you ask for the SENSORS value:
component_event (1)

Had you been using TinyDB, you could have gotten the results immediately and set your text color and location sensor enabled attribute.

But if you use Firebase you would need to grab the SENSORS value after asking for it in those two event blocks.

Seeing how you are using the Location Sensor, be aware that screens are separate programs, and switching them breaks connections to Bluetooth and GPS.

can i have an example block using tinydb with regards to my app? cause i use firabase to send its data to raspberry pi thanks in advance

It's easier to just stick to one Screen and switch visibility of stacked Vertical Arrangements.

You can copy Screens in the Designer using Ctrl-C and paste them into Arrangements using Ctrl-V.