Showing multiple messages on an OLED

Hello

I am making an alarm control panel with a 20m2 that will have 4 alarm inputs, some outputs and the alarms displayed on a Picaxe 16 x 2 OLED display.

Getting the display to work correctly from the 20m2 is OK but...

How to display more than 1 alarm in a cyclic style is my question.

If alarm 2 is triggered the display will show "alarm 2" then if alarm 4 is triggered "alarm 2" and "alarm 4" need to keep cycling until the system is attended.

What may happen is alarm 2 triggers, then a couple of minutes later another alarm will occur (alarm 4), so whoever attends needs to view all the alarms.

To work properly it will need to be able to show and cycle upto 4 inputs.

If all else fails I can use a 20 x 4 OLED with one alarm on each line but I was hoping for a more elequent answer, just incase Alarm 5 rears it's head!

If someone can put me on the track of how to add and stack alarms and keep cycling round I would be very grateful.

The alarm text can come from the 20m2 or use the on board stored messages in the OLED

Thanks for reading
 

Buzby

Senior Member
There a few ways to display multiple alarms, but if you have a bit for each alarm then the easiest way is probably this :
do
if AlarmBit1 = 1 then : display alarm 1 : pause 1000 : endif
if AlarmBit2 = 1 then : display alarm 2 : pause 1000 : endif
if AlarmBit3 = 1 then : display alarm 3 : pause 1000 : endif
loop

This will display each active alarm in turn for 1 second. ( You will need to add a tiny bit of code to handle the no alarms condition. )

More complex scrolling alarm lists are possible, but this method is simple. ( It's a bit different if you need to handle a few thousand alarms. )

Cheers,

Buzby
 

hippy

Technical Support
Staff member
You presumably have a flag for each alarm triggered so you could build an appropriate message every time a new alarm triggers "Alarms 1 & 2", even track the order alarms went off; "Alarms 1 3 2 4".

You might have to define how you mean by stacking alarms and what you mean by cycling them. It's hard to supply 'how to' when it's not clear what you want to see.
 

lbenson

Senior Member
It won't help for Alarm #5, but this program illustrates how you can show up to 4 alarms. Run it in the simulator with the 16x2 LCD turned on for C.0:
alarm1234.jpg
Code:
#picaxe 14M2
'#terminal 9600

symbol RandomValue=w13
symbol alarmNo=b1

RandomValue = 48611 ' seed with large prime number which fits in a word
do
  serout C.0,n2400,(254,1) ' clear
  pause 10
  serout C.0,n2400,(254,128) ' line 1
  serout C.0,n2400,("Alarm 1 Alarm 2")
  serout C.0,n2400,(254,192) ' line 2
  serout C.0,n2400,("Alarm 3 Alarm 4")
  pause 2000
  serout C.0,n2400,(254,1) ' clear
  do
    random RandomValue
    alarmNo=RandomValue // 4 + 1 ' number between 1 and 4
    select alarmNo
      case 1
        serout C.0,n2400,(254,128) ' line 1, alarm1 position
        if bit0 = 0 then
          serout C.0,n2400,("Alarm 1")
        else
          serout C.0,n2400,("        ")
        endif
        bit0 = bit0 + 1 ' toggles between 0 and 1
      case 2 
        serout C.0,n2400,(254,136) ' line 1, alarm2 position
        if bit1 = 0 then
          serout C.0,n2400,("Alarm 2")
        else
          serout C.0,n2400,("        ")
        endif
        bit1 = bit1 + 1 ' toggles between 0 and 1
      case 3
        serout C.0,n2400,(254,192) ' line 1, alarm1 position
        if bit2 = 0 then
          serout C.0,n2400,("Alarm 3")
        else
          serout C.0,n2400,("        ")
        endif
        bit2 = bit2 + 1 ' toggles between 0 and 1
      case 4
        serout C.0,n2400,(254,200) ' line 1, alarm1 position
        if bit3 = 0 then
          serout C.0,n2400,("Alarm 4")
        else
          serout C.0,n2400,("        ")
        endif
        bit3 = bit3 + 1 ' toggles between 0 and 1
    end select
    pause 2000
  loop
loop
Or you could use hippy's suggestion, "Alarm: #,#,#,#,#" with additional numbers on second line.
 

papaof2

Senior Member
How many characters do you need to displayfor each alarm?

If less than 8 characters, use screen addressing and place each of the 4 alarms in its own quadrant.
"HI TEMP", "LO TEMP", "DOOR 12" are each 7 characters.

If the alarms need 8 or more characters to identify them, display alarms 1 and 3 alternately on line 1 and alarms 2 and 4 alternately on line 2. That might allow a 500ms update of each line so the data for a given line could be in place 1 second, depending on the active alarms.
 
Thank you for the replies.

The reason for using an OLED is the alarm will be attended by people who will not have knowledge of the system but can then contact someone who does, so the whole display will have a better description, it will not be "alarm 1".

What I needed was help with how to display multiple alarms.

To show a single message that does not change is easy.

The problem is, when the alarm is triggered, how would you add additional signals that then rotate on the display in a viewable manner.

Each alarm message has not only the information but the delay it is viewed for, so I needed help in arranging the message viewing delay and then how do you go to the next and the next and come back to the initial alarm and keep rotating round the display until people respond.

I can use four gosub commands one for each message and tie the commands, delays, clear display etc for each message in the gosub.

This seems the best way for me so I will have a go and see how it gets on.
 

lbenson

Senior Member
This will run in the simulator and display 4 unique messages (or as many as you have input pins) in sequence, each message on for 2 seconds.
Code:
#picaxe 14M2
'#terminal 9600

symbol bits=b0 ' reserved for bit values
symbol oldAlarmBits = b1
symbol alarmBits = b2
symbol alarmNo=b3

dirsC=%000001 ' all inputs except C.0
do
  serout C.0,n2400,(254,1) ' clear
  pause 10
  if pinC.1 = 1 then
    serout C.0,n2400,("Alarm 1 Line 1")
    pause 10
    serout C.0,n2400,(254,192) ' line 2
    pause 10
    serout C.0,n2400,("Alarm 1 Line 2")
    pause 2000
  endif    
  if pinC.2 = 1 then
    serout C.0,n2400,(254,1) ' clear
    pause 10
    serout C.0,n2400,("Alarm 2 Line 1")
    pause 10
    serout C.0,n2400,(254,192) ' line 2
    pause 10
    serout C.0,n2400,("Alarm 2 Line 2")
    pause 2000
  endif    
  if pinC.3 = 1 then
    serout C.0,n2400,(254,1) ' clear
    pause 10
    serout C.0,n2400,("Alarm 3 Line 1")
    pause 10
    serout C.0,n2400,(254,192) ' line 2
    pause 10
    serout C.0,n2400,("Alarm 3 Line 2")
    pause 2000
  endif    
  if pinC.4 = 1 then
    serout C.0,n2400,(254,1) ' clear
    pause 10
    serout C.0,n2400,("Alarm 4 Line 1")
    pause 10
    serout C.0,n2400,(254,192) ' line 2
    pause 10
    serout C.0,n2400,("Alarm 4 Line 2")
    pause 2000
  endif    
loop
In the simulator, click pins C.1, C.2, C.3, C.4 on and off in any sequence to display the alarm messages sequentially for as long as the pins remain on.
[Note added: a clear command has to be put after the DO to clear any remaining message when no pins are active--code modified.]
 
Last edited:
Top