|
IoT-MBBR (masterthesis)
Masterthesis upgrading a Moving Bed BioReactor with extra sensors and cloud connectivity.
|
Sparkfun serLCD functionality. More...
#include <stdint.h>#include <stdbool.h>#include "em_device.h"#include "em_cmu.h"#include "em_gpio.h"#include "em_i2c.h"#include "serlcd.h"#include "debug_dbprint.h"#include "pin_mapping.h"#include "i2c.h"Go to the source code of this file.
Macros | |
| #define | DISPLAY_ADDRESS 0x72 /* This is the default address of the OpenLCD (7 bit notation) */ |
| #define | SPECIAL_COMMAND 254 /* Magic number for sending a special command */ |
| #define | SETTING_COMMAND 0x7C /* 124, |, the pipe character: The command to change settings: baud, lines, width, backlight, splash, etc */ |
| #define | CLEAR_COMMAND 0x2D |
| #define | CONTRAST_COMMAND 0x18 |
| #define | ADDRESS_COMMAND 0x19 |
| #define | SET_RGB_COMMAND 0x2B |
| #define | ENABLE_SYSTEM_MESSAGE_DISPLAY 0x2E |
| #define | DISABLE_SYSTEM_MESSAGE_DISPLAY 0x2F |
| #define | ENABLE_SPLASH_DISPLAY 0x30 |
| #define | DISABLE_SPLASH_DISPLAY 0x31 |
| #define | SAVE_CURRENT_DISPLAY_AS_SPLASH 0x0A |
| #define | LCD_RETURNHOME 0x02 |
| #define | LCD_ENTRYMODESET 0x04 |
| #define | LCD_DISPLAYCONTROL 0x08 |
| #define | LCD_CURSORSHIFT 0x10 |
| #define | LCD_SETDDRAMADDR 0x80 |
| #define | LCD_ENTRYRIGHT 0x00 |
| #define | LCD_ENTRYLEFT 0x02 |
| #define | LCD_ENTRYSHIFTINCREMENT 0x01 |
| #define | LCD_ENTRYSHIFTDECREMENT 0x00 |
| #define | LCD_DISPLAYON 0x04 |
| #define | LCD_DISPLAYOFF 0x00 |
| #define | LCD_CURSORON 0x02 |
| #define | LCD_CURSOROFF 0x00 |
| #define | LCD_BLINKON 0x01 |
| #define | LCD_BLINKOFF 0x00 |
| #define | LCD_DISPLAYMOVE 0x08 |
| #define | LCD_CURSORMOVE 0x00 |
| #define | LCD_MOVERIGHT 0x04 |
| #define | LCD_MOVELEFT 0x00 |
Functions | |
| int8_t | clearLCD (void) |
| Clear the LCD. More... | |
| int8_t | writeCharLCD (uint8_t data) |
| Write a character (one byte) to the LCD. More... | |
| int8_t | writeStringLCD (char *message) |
| Print a string (char array) to the LCD. More... | |
| int8_t | setCursorLCD (uint8_t col, uint8_t row) |
| Set the cursor to a specific location on the LCD. More... | |
| int8_t | heartBeatLCD (void) |
| Update the heartbeat icon. More... | |
Variables | |
| bool | heartBeat = false |
Sparkfun serLCD functionality.
Copyright (C) 2020 - Brecht Van Eeckhoudt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License can be found in the LICENSE file along with this source code.
Some methods use code obtained from examples from Silicon Labs' GitHub. These sections are licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.
Code based on: https://github.com/sparkfun/SparkFun_SerLCD_Arduino_Library/blob/master/src/SerLCD.cpp
ASCII / DEC / HEX '|' / 124 / 0x7C - Put into setting mode Ctrl+c / 3 / 0x03 - Change width to 20 Ctrl+d / 4 / 0x04 - Change width to 16 Ctrl+e / 5 / 0x05 - Change lines to 4 Ctrl+f / 6 / 0x06 - Change lines to 2 Ctrl+g / 7 / 0x07 - Change lines to 1 Ctrl+h / 8 / 0x08 - Software reset of the system Ctrl+i / 9 / 0x09 - Enable/disable splash screen Ctrl+j / 10 / 0x0A - Save currently displayed text as splash Ctrl+k / 11 / 0x0B - Change baud to 2400bps Ctrl+l / 12 / 0x0C - Change baud to 4800bps Ctrl+m / 13 / 0x0D - Change baud to 9600bps Ctrl+n / 14 / 0x0E - Change baud to 14400bps Ctrl+o / 15 / 0x0F - Change baud to 19200bps Ctrl+p / 16 / 0x10 - Change baud to 38400bps Ctrl+q / 17 / 0x11 - Change baud to 57600bps Ctrl+r / 18 / 0x12 - Change baud to 115200bps Ctrl+s / 19 / 0x13 - Change baud to 230400bps Ctrl+t / 20 / 0x14 - Change baud to 460800bps Ctrl+u / 21 / 0x15 - Change baud to 921600bps Ctrl+v / 22 / 0x16 - Change baud to 1000000bps Ctrl+w / 23 / 0x17 - Change baud to 1200bps Ctrl+x / 24 / 0x18 - Change the contrast. Follow Ctrl+x with number 0 to 255. 120 is default. Ctrl+y / 25 / 0x19 - Change the TWI address. Follow Ctrl+x with number 0 to 255. 114 (0x72) is default. Ctrl+z / 26 / 0x1A - Enable/disable ignore RX pin on startup (ignore emergency reset) '+' / 43 / 0x2B - Set RGB backlight with three following bytes, 0-255 ',' / 44 / 0x2C - Display current firmware version '-' / 45 / 0x2D - Clear display. Move cursor to home position. '.' / 46 / 0x2E - Enable system messages (ie, display 'Contrast: 5' when changed) '/' / 47 / 0x2F - Disable system messages (ie, don't display 'Contrast: 5' when changed) '0' / 48 / 0x30 - Enable splash screen '1' / 49 / 0x31 - Disable splash screen / 128-157 / 0x80-0x9D - Set the primary backlight brightness. 128 = Off, 157 = 100%. / 158-187 / 0x9E-0xBB - Set the green backlight brightness. 158 = Off, 187 = 100%. / 188-217 / 0xBC-0xD9 - Set the blue backlight brightness. 188 = Off, 217 = 100%. For example, to change the baud rate to 115200 send 124 followed by 18.
Definition in file serlcd.c.
| #define DISPLAY_ADDRESS 0x72 /* This is the default address of the OpenLCD (7 bit notation) */ |
| #define SETTING_COMMAND 0x7C /* 124, |, the pipe character: The command to change settings: baud, lines, width, backlight, splash, etc */ |
| #define SPECIAL_COMMAND 254 /* Magic number for sending a special command */ |
| int8_t clearLCD | ( | void | ) |
Clear the LCD.
This method also initializes i2C if necessary.
0 - Byte written correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 168 of file serlcd.c.
| int8_t heartBeatLCD | ( | void | ) |
Update the heartbeat icon.
This method also initializes i2C if necessary.
0 - Byte written correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 361 of file serlcd.c.
Set the cursor to a specific location on the LCD.
This method also initializes i2C if necessary.
| [in] | col | Column (uint8_t, MAX = 20). |
| [in] | row | Row (uint8_t, MAX = 4). |
0 - Byte written correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 316 of file serlcd.c.
Write a character (one byte) to the LCD.
This method also initializes i2C if necessary.
| [in] | data | The data (uint8_t) to put on the I2C bus. |
0 - Byte written correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 214 of file serlcd.c.
| int8_t writeStringLCD | ( | char * | message | ) |
Print a string (char array) to the LCD.
"Hello world!") but a char array, the input message (array) needs to end with NULL ("\0")!This method also initializes i2C if necessary.
| [in] | message | The string to print to the LCD. |
0 - Byte written correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 264 of file serlcd.c.