![]() |
Forum Index : Microcontroller and PC projects : Micromite V5.04.09 Beta 3
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
I have a new beta version of the Micromite firmware available. It can be downloaded from: http://geoffg.net/Downloads/Micromite/Micromite_V5.04.09_Beta.zip This includes the fix for issues with corrupted 5" displays (discussed in another thread) and adds the ability to write display drivers in BASIC (rather than just using CFunctions). Peter Mather is planning some new display drivers using this facility and it will be fascinating to see what he comes up with. My plan for future beta versions is to keep adding small improvements (incrementing the beta number) and keep the beta open for some months until it has accumulated enough changes and is stable enough to warrant a full release. If you find any bugs please let me know. Geoff Geoff Graham - http://geoffg.net |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Would that mean that the console would also use that display driver? Microblocks. Build with logic. |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
No, using an LCD panel as the console on the MM+ requires a SSD1963 based panel. This is because the SSD1963 supports hardware scrolling. Other than this a driver written in BASIC looks like a built in driver, you can select fonts, draw lines, use MM+ controls, etc. However it will be slower so it is best suited to small displays (ie, 128x32 pixels). Geoff Graham - http://geoffg.net |
||||
LewW Newbie ![]() Joined: 16/01/2018 Location: AustraliaPosts: 15 |
Hi Geoff, Thanks for V5.04.09_Beta_9 I have just installed it on my E100, and it has resolved all my 5" SSD1963 display problems. Note that when I reset the E100, it indicates V5.04.09 Beta 4. Best wishes, Lew. |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
Yes, my plan is too keep updating the beta, if it is a significant change I will announce it on this forum. Geoff Graham - http://geoffg.net |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
There is a new beta version (Beta 10) for anyone who would like to experiment with it: http://geoffg.net/Downloads/Micromite/Micromite_V5.04.09_Beta.zip It includes a new command STATIC. This is similar to LOCAL except that the variables created will retain their value between calls to the subroutine or function. The syntax is exactly the same as DIM. This version also includes the bug fixes of all previous betas... see the change log for the details. Geoff Geoff Graham - http://geoffg.net |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
I know this STATIC command was on the list for some time. I am happy that you found a way to do it. This will make programming so much easier and tidier (especially library functions). A big thanks from me! Microblocks. Build with logic. |
||||
PicFan Senior Member ![]() Joined: 18/03/2014 Location: AustriaPosts: 133 |
Hello Geoff! Thanks for the new version, the "static" command is very important! Unfortunately I have a little problem: 1.) Problem: (MX170 and MX470) DIM x = 1 RUN> ERROR: variable name 2.) Problem: (MX170, 44pol.) OPTION AUTORUN ON DIM x = 1 RUN> CPU exception # 7 at adress 0x9D03DE78 Processor restarteä CPU exception # 7 at adress 0x9D03DE78 Processor restarteä CPU exception # 7 at adress 0x9D03DE78 Processor restarteä . . . . . The system hangs up, Ctrl-C, as well as Reset has no effect. USB is no longer recognized, reprogramming with the PICKIT is required. 2.) Problem: (MX470) OPTION AUTORUN ON DIM x = 1 RUN> The system hangs up, Ctrl-C, as well as Reset has no effect. USB is no longer recognized, reprogramming with the PICKIT is required. Thank you ! Wolfgang |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Can one of you in the know, explain to me why STATIC is so useful? LOCAL is local to the sub - I get that. They are disposed of when the sub exits. If STATIC remains between calls, isn't that exactly the same a just having a global DIM variable that is visible to everything in the code at any time? I know I am missing something, but I just don't know what at this point. Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
LOCAL is useful because you don't have to worry about functions that use variables with the same name. This is usually a problem when you reuse subs/functions. If you have to use global's to retain values, you loose that advantage. STATIC saves the dilemma. It's not a common 'must have' but it is very handy when making reusable functions. I will have to experiment to see what happens to STATIC variables in functions in the library. Will the values survive program restarts? Jim VK7JH MMedit |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I have run a few tests. If the FUNCTION that uses STATIC in saved in the LIBRARY, any STATIC variables are reinitialised with program start/stop so that is OK. The problem with DIM occurs on 28 pin micromites but NOT in DOS_MMBasic This program errors on the micromite MX170 with DIM, runs OK on DOS as is and runs OK on micromite with DIM removed. Jim VK7JH MMedit |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
Thanks guys. Something has seriously gone wrong. Give me a day and I try to find out what the problem is. Geoff Geoff Graham - http://geoffg.net |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
So, is STATIC a variable that is ONLY visible to subs and functions, and is not visible to the rest of the running code? Some kind of 'Static variable' that will remain across calls to a sub or function? Could you not do that with CONST? Sorry - still don't really understand this.... ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
A LOCAL variable is reset to zero (or "") whenever the SUB/Function is called. A STATIC variable is the same as LOCAL except it's value is NOT reset each time the SUB/FUNCTION is called. It retains the value it had when the SUB/FUNCTION was last exited. You could do it all with global variables, just as you could do without LOCAL variables, but this way produces more modular code. It is not like a CONST. The STATIC name refers to it remaining static between subsequent calls to the SUB, not static all the time. Jim VK7JH MMedit |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
With a CONST you cannot change its value. A STATIC is a variable that you can change (like a LOCAL) but will retain its value (like a global variable created by DIM). Say, for example, that you need a function to detect a switch press and print a suitable message. This function will be called repeatedly from various parts of your program. Your code could look like this: SUB SwPressed IF PIN(xxx) = 0 THEN ' if switch pressed PRINT "Switch has been pressed" ENDIF END SUB The problem with this is that while your finger is held down on the switch the message will rapidly repeat and scroll up the screen. Not good, you wanted just one message. So you could rewrite it like this (we are ignoring debounce issues): DIM SwState = 0 'define a global var to keep track of the switch SUB SwPressed IF PIN(xxx) = 0 THEN ' if switch pressed IF SwState = 0 THEN ' if we have not seen this before PRINT "Switch has been pressed" SwState = 1 ' show that we have seen the press ENDIF ELSE SwState = 0 ' record that the switch has been released ENDIF END SUB Now you are using the global variable SwState to track if the message has been printed and only print it once. But using a global variable is messy and if you are monitoring many switches you will need many global variables. You will also have the chance of clashing with other globals and tearing out what remaining hair that you have. STATIC fixes that: SUB SwPressed STATIC SwState = 0 'define a static var to keep track of the switch IF PIN(xxx) = 0 THEN ' if switch pressed IF SwState = 0 THEN ' if we have not seen this before PRINT "Switch has been pressed" SwState = 1 ' show that we have seen the press ENDIF ELSE SwState = 0 ' record that the switch has been released ENDIF END SUB Now the subroutine is neatly self contained. In a more general sense you normally use STATIC to keep track of the state of something while inside a sub/fun. For example, is this com port open or closed? Have we received this message or not? What steps in a sequence have we completed? All of these involve the state of the program. In the past you would use DIM to create global variables to keep track of the state, now you can use STATIC. Just like LOCAL the use of STATIC helps to make your subroutines and functions more self contained and portable but its use is not mandatory. Geoff Geoff Graham - http://geoffg.net |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
I have fixed the bug in Beta 10 that stopped STATIC and DIM from working. Anyone interested in playing with the new version (Beta 11) can download it from: http://geoffg.net/Downloads/Micromite/Micromite_V5.04.09_Beta.zip When you get used to them STATIC variables can be quite useful, especially as they reduce the need for global variables created with DIM. Geoff Geoff Graham - http://geoffg.net |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
So, using your example above, I don't see the difference between: SUB SwPressed STATIC SwState = 0 'define a static var to keep track of the switch IF PIN(xxx) = 0 THEN ' if switch pressed IF SwState = 0 THEN ' if we have not seen this before PRINT "Switch has been pressed" SwState = 1 ' show that we have seen the press ENDIF ELSE SwState = 0 ' record that the switch has been released ENDIF END SUB ....and this one: SUB SwPressed LOCAL SwState = 0 'define a static var to keep track of the switch IF PIN(xxx) = 0 THEN ' if switch pressed IF SwState = 0 THEN ' if we have not seen this before PRINT "Switch has been pressed" SwState = 1 ' show that we have seen the press ENDIF ELSE SwState = 0 ' record that the switch has been released ENDIF END SUB In the lower example using LOCAL, the value of SwState will be lost when the sub exits - I get that fine. But if STATIC is supposed to remain across calls to subs and functions, then STATIC SwState=0 will clear it anyway, so LOCAL would be a more usual choice would it not? ![]() In this example: SUB BLAH1 LOCAL A ... END SUB ...the variable 'A' will exist inside the sub, and vanish once the sub exits - also returning any memory it was using to the memory pool. That is fine. I understand LOCAL. In this example: SUB BLAH2 STATIC A A=1 ... END SUB ...the variable 'A' will remain with the value of 1 even when the sub exits, correct? This static variable is NOT visible to the rest of the code, correct? If you call this sub again, A will still be equal to 1 unless you change it, correct? Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Yes Jim VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Ahhhhh, OK, thanks. ![]() I think I have cottoned on to what that is all about now. Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
This example might make things clearer Run it for a while with the occasional keypress I often need to measure elapsed time so STATIC will be handy Jim VK7JH MMedit |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |