BSA2-无代写
时间:2023-05-31
BSA2-MC
Project Guidelines – Display
Introduction
Liquid crystal displays, or LCDs for short, consist of a large area of liquid crystals that rotate the
polarization plane of the light under the influence of an electric field. If such a display is illuminated
by already polarized light, these crystals appear more or less light or dark. The voltage applied is
very low, but it must be an alternating voltage, as a direct voltage decomposes the crystals.
In our case a DOGM162-A display is used on an adapter board for the Arduino UNO.
In addition to the display, this adapter board also has 4 buttons (attention: the 5th button is the
reset button) and 3 LEDs.
Display – SPI
The DOGM display is connected via the Serial Peripheral Interface (SPI) interface. SPI is a
synchronous interface, so an explicit clock signal is used (SCLK, often also called SCK or SCL).
The data transfer from the Arduino to the display takes place via the MOSI line (master out, slave
in). The MISO (Master In, Slave Out) line is used in the other direction. The slave select line (often
also called ChipSelect CS) is used to activate the SPI device. If this line is high, the SPI device is
deactivated. If the CS line is set to low, communication can be carried out with this SPI device.
2
Tip: The SPI communication is already implemented in the project template, as are the
corresponding functions for controlling the display.
Tip: The dogm lcd.h file contains the relevant functions for the display, the most important of
which are:
 lcdClear() → deletes all display content
 lcdSetCursor(uint8_t row, uint8_t col) → sets the cursor to the specified position for writing.
lcdSetCursor (0,0) starts in the upper left corner.
 lcdWriteChar(char x) → Writes this character at the current cursor position and increments
the cursor to the next column.
 lcdSpiInit() → Initializes SPI
 lcdInit() → Initializes tje Display (lcdSpiInit() must be called first).
LEDs & Buttons
4 buttons are connected to the adapter board: PD2, PD3, PD4, PD5
3 LEDs are connected to the adapter board: PD6, PD7, PB0
3
Menü
In order to be able to use the universal remote control, a menu is required on the display.
Furthermore, the operation should work in the same way via the UART interface.
It is operated using the buttons on the display board.
When these buttons are pressed, the display is updated, as is the menu output on the UART! If an
arrow key is pressed on the PC, the display should also be updated in addition to the output on the
UART.
Our suggestion for the output:
 Line 1: currently selected command ("record", "replay", "delete")
 Line 2: current status (e.g. "ready", "recording done", "replay done")
The output on the display takes place via the functions described in the previous chapter. So-called
ANSI escape sequences are used for the menu output on the UART interface (see:
https://de.wikipedia.org/wiki/ANSI-Escapesequenz).
For this, the LCD functions have to be expanded a bit. In the following part the corresponding
functions are provided, which send the correct ANSI codes:
 lcd_clear: uart_sendstring("\033[2J");
 lcd_setcursor:
void uart_setcursor( int x, int y)
{
char text[30];
sprintf(text,"\033[%d;%df", y,x );
uart_sendstring(text);
}
 lcd_writeChar: just use uart_transmit() for writing a character
Tip: In order to switch from one character to the next (e.g. "a" → "b") the character variable can
simply be incremented. Please check the corner cases: “z” → cannot simply be incremented to “a”!
When using the buttons, it should be possible to press the button permanently. The letters are then
automatically incremented (e.g. every 200ms).
4
Tip: There is no button for "Enter" on the board. Therefore, if you press the right button for a long
time, the entry should be accepted (name of the IR command to be recorded). A long press on the
left button should also cancel the entry and return to the main menu.
The way of entering the name is freely selectable, our suggestion would be:
 If "Record" is selected, the entry of the name starts at the first position
 With “up” / “down” (buttons & UART) it should be possible to select the character at this
point. Minimum requirement for selectable characters: a-z & 0-9
 With "left" / "right" it should be possible to switch to the previous / next position
 With a long press on "right" the entry is confirmed (min. Length of the name: 2 characters)
 A long press on "left" cancels and returns to the main menu.
Tip: The ui_get_selection function is called in our source code template. You should block
this function until one of the commands has been selected and the parameters are correct
("record": name must match, "replay": selection must be converted to a valid command number).
The further process is then ensured by our main.c.
5
Schematic of the LCD Addon
Sources
DOGM162-A datasheet
https://de.wikipedia.org/wiki/Serial_Peripheral_Interface
essay、essay代写