![]() |
Forum Index : Microcontroller and PC projects : Help with LED.
Author | Message | ||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Anyone got any suggestion or up for a challenge with this? I think it would be useful to be able to blink a GUI LED. The Challenge is how? Started this simple bit of code as a framework, but can see a few things that need consideration. Using PAUSE is not a real option, I only put it there for my first demo to see a result on the screen. I know that's not evenly remotely the right approach. Second to that, this could only work with a single GUI LED at any time. Assuming I wanted to flash, say 4 LED's I presume their Timer on value may need to be stored in an Array, so the function or sub would know when they have been illuminated for the prescribed period. This is the VERY SIMPLE framework I have started with. [Code]'Flash Led Option Explicit Option Default None Dim Integer L_StatLed1=1,n CLS GUI LED L_StatLed1, "Test LED", 100, 100, 100, RGB(Red) For n=1 to 10 FlashLed (L_StatLed1,300) 'Blink the GUI LED for 300ms Pause 1000 'Flash it again after 1 second. Next n 'Function FlashLed Sub FlashLed (LedID as Integer,Duration as Integer) As Integer CtrlVal(LedID)=1 Print "LED On" Pause Duration CtrlVal(LedID)=0 Print "LED Off" End Sub 'End Function[/code] As I said, I know it's wrong, just demonstrates. Thanks Phil. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
I might be way off the mark, but I think this will do what you are after An array holds the desired state of each gui element. Keep the nuimbers consecutive to make life easier. If you want to flash a LED, set its array element to '1' To stop flashing, set zero and to flash inverted (off when the others are on) set '2' When they are not flashing you can still turn them on and off as normal. I haven't done any GUI programming yet so the example is very basic. Touch on the left side of the display to have LED 3 inverted, right side for in phase. Jim VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
|
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
I would go with the simple choice: Turn the LED on at the start of the comms receive routine and off at the end. The more data, the longer the LED is on for. Simple and a good indicator of activity. I will talk to Glenn and see how we are going to get rid of the double spacing. Luckily, MMEdit has a get-rid-of-blank-lines function. Jim VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
That's basically what I'm doing at one of the slave ends at present, needs a 150ms pause to make the LED noticeable. The other has a physical Led that's much more easily visible. That slave has no display. On the Master I've resorted to inverting the Led on each successful receipt of coms. On & off at the start & end of the routines didn't work on the MM+ as it's processing is too quick. Similarly, early on I had a status Led that inverted each time the main loop was run. You could tell all was running easily from a distance. Had to reclaim that pin, so it's a graphic led now (28p backpack). Thanks Phil. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |