Until now deep sleeping the device uses a 1 second watchdog timer in a loop to put it in a low power mode for a set amount of time.
But what if we want it to go into deep sleep until a button is pressed?
Here is where the 3 different modes of deep sleep have been implimented.
- Mode 0: This is the deepsleep mode that gets triggered if VCC<2v, nothing but a charge will wake it up. Get it to the sunlight!
- Mode 1: This is our timed deepsleep we can set from code, (now keywords D1-D8). I have now implimented the [R]un button to be set as an interrupt when entering this mode. So if we put it in that mode and want to wake it up, its easy.
- Mode 2: This puts the device in an infinite deepsleep. The only thing that will wake it up is the button press. This may be a good mode to set it at if there is no user input detected for x amount if time.
I have also setup the [R]un button to stop the running program. The choice for this button other than it being the one that is used to run the program, is that it is directly connected to ground when pressed. So it is the only button that will provide a logic 0 for the interrupt.
The only issue with this is it the program is for example flashing an LED, and there is a 1s delay in between flashes, we have to hold the button down until the delay is over. It seems using a timer to control the delay in code interpretation may be a better choice than directly calling delay() in the parser.
Other than that, all I have done with the code is a lot of cleanup and commenting.
Once I implement Pin control in the interpreter, PB2 will also be able to be used as an interrupt. Pin control and the option to access button presses within the interpreter are coming next.
Other than that, the only new feature I plan on adding is the ability for TGRK programs to save data in the unused bytes at end of eeprom.
Below are some screenshots of all keywords(i havent added eeprom data keywords yet to list). Green is complete, yellow and orange are partially complete, red is incomplete.
I have changed all keywords(was calling OPs before) to short, uppercase text that can be set as macros in C program, allowing quick and intuitive testing.
I also removed the [ , ] previously used for dividing expressions and the [ = ] that was going to be an optional way to assign value to register. But while cleaning up code realized these were unnecessary and redundant. The goal is maximum simplicity. Below is a simple program:
R1 20 SEP CG R1 0 R1 SUB 1 L0H S1 L0L S1 LP SEP EOP
This program blinks LED0 20 times.
The LP keyword will scan backward until it hits SEP(previously :), FUNC (previously #), or program index 0. We could write a blink program that blinks LED1 every second forever like this:
L1H S1 L1L S1 LP
Thats as simple as a blink program gets in TGRK! EOP is technically not needed, but i like having it there for some reason. And if the program is only one expression like the one above, there is no need for SEP at all.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.