Skip to content

Programming Maroon Shield

philippbruhin edited this page May 19, 2022 · 9 revisions

This chapter describes how to communicate from the view of NIBO Burger with the 8x8 pixel matrix display Maroon Shield via UART.

Remember, UART does stand for Universal Asynchronous Receiver-Transmitter. Asynchronous does mean there is no clock like in I²C or SPI.

I²C and SPI are both – in contrast to UART – synchronous organized.

With UART, packages consisting of the following bits are sent:

UART
Image source

The package as a whole is synchronized with the start bit but the individual bits are sent asynchronously.

Because of there is no clock in UART, a baud rate needs to be specified on the sender (NIBO Burger robot) and receiver (Maroon Shield). This allows the recipient to assign the bits to the appropriate position.

Maroon Shield is configured as follows:

  • 38'400 baud (38'400 bits/s or 4800 bytes/s)
  • 8 bit
  • no parity
  • 1 stop bit

Therefore the robot's communication needs to be setup as follows:

usart_setbaudrate(38400);
usart_enable();

A small program that outputs "Hello" as horizontal scrolling text could look as follows.

#include <niboburger/robomain.h>

void setup() {
    usart_setbaudrate(38400);
    usart_enable();
    
    delay(500);
    
    // print "Hello" on the display once 
    usart_write("Hello");
}

void loop() {

}

The 64 pixel can all be controlled individually. Following example shows a chess board. Every second LED lights up.

// display chess pattern without scrolling
usart_write("\33l\33Gaa55aa55aa55aa55 ")

The example below shows a Swiss cross. Every column is represented by a hex number, starting from 00 (all 8 LEDs off) to ff (all 8 LEDs on).

// display swiss cross
usart_write("\33l\33Gffe7e78181e7e7ff ")

maroon_shield_swiss_cross

The protocol can be found on nibo-roboter.de/wiki/Maroon_Shield in German language or following as English copy. Work with the protocol to activate special functions!

Protocol

The Maroon Shield shows UNICODE and thus also ASCII texts on the 8x8 LED pixel display. To activate special functions one can send the escape sequences listed below to the display.

[ESC] ASCII escape character (hexadecimal: 0x1b / decimal: 27)
[DLE] Ascii Data Link Escape Character (hexadecimal: 0x10 / decimal: 16)
{n} single digit
{c} single character
{xxx} multiple characters
<*> implemented
< > not implemented yet

Stream commands

<*> [ESC]c - clear display
< > [ESC]r - repeat begin
< > [ESC]s - repeat start
<*> [ESC]b{n} - set matrix brightness to n=[0-9: 0-90%, *: 100%]
<*> [ESC]d{n} - dimm matrix brightness to n=[0-9: 0-90%, *: 100%]
< > [ESC]o{c} - set matrix orientation c=[n,w,e,s: North, West, East, South]
<*> [ESC]t{c} - transmit back char (synchronisation) c=[ASCII char]
<*> [ESC]l - load next matrix bytes without delay
    font modifiers:
<*> [ESC]e1 - economy font size (3×6)
<*> [ESC]e0 - normal font size (5×8)
< > [ESC]i1 - inverted output
< > [ESC]i0 - noninverted output
< > [ESC]p1 - proportional mode
< > [ESC]p0 - fixed width mode

<*> [ESC]B{xxxxxxxx}[SPACE] - Bargraph mode, every char is a colon, terminated by space
<*> [ESC]G{xxxxxxxx}[SPACE] - Grafic mode, bytes are hexadecimal encoded, terminated by space
<*> [ESC]P{xxx}[SPACE] - Pause given time in miliseconds
<*> [ESC]S{xxx}[SPACE] - set shift delay time (ms)
<*> [ESC]D{xxx}[SPACE] - set matrix dimm transition time (ms)
<*> [ESC]T{n}{xxx}[SPACE] - matrix dimm transition value and time
< > [ESC]X{xxx}[SPACE] - hexadecimal to decimal conversion

Following example clears the display of a NIBO Burger Maroon Shield:

usart_write("\33c");

Immediate commands

<*> [DLE]c - clear and reset display
<*> [DLE]d{n} - set matrix dimm value to n=[1-9: 10-90%, 0: 100%]
< > [DLE]o{c} - set matrix orientation c=[n,w,e,s: North, West, East, South]

Bargraph mode

'0'-'8' single dot
'a'-'i' bar ascending
'i'-'q' bar descending
'A'-'E' center bar fading in
'E'-'I' center bar fading out