Commit 6593eb6e450890b6e941cfd1725b2d281410fdab

Authored by Enrique Díaz Roque
1 parent 4192e9f4
Exists in master and in 1 other branch dev

update master

tests/LCD/lib/LCD/LCD.cpp
... ... @@ -2,17 +2,37 @@
2 2  
3 3 LCD::LCD() {
4 4 lcd_addr = DEFAULT_ADDRESS;
5   - setup();
  5 + lcd_setup();
6 6 }
7 7  
8 8 LCD::LCD(byte lcd_addr) {
9 9 this->lcd_addr = lcd_addr;
10   - setup();
  10 + lcd_setup();
11 11 }
12 12  
13   -LCD::setup() {
  13 +void LCD::lcd_setup() {
14 14 Wire.begin();
15 15 // check if device exists
16 16 }
17 17  
  18 +void LCD::command(byte cmd) {
  19 + Wire.write(COMMAND);
  20 + Wire.write(cmd);
  21 +}
  22 +
  23 +void LCD::backlight(bool state) {
  24 + Wire.beginTransmission(lcd_addr);
  25 + if (state) {
  26 + command(BACKLIGHT_ON);
  27 + } else {
  28 + command(BACKLIGHT_OFF);
  29 + }
  30 + Wire.endTransmission();
  31 +}
  32 +
  33 +void LCD::clear_screen() {
  34 + Wire.beginTransmission(lcd_addr);
  35 + command(CLEAR_SCREEN);
  36 + Wire.endTransmission();
  37 +}
18 38  
... ...
tests/LCD/lib/LCD/LCD.h
1 1 /*
2   - Heisenwave's LCD
  2 + Heisenwave's LCD05
3 3 */
4 4  
5 5 #ifndef LCD_H
... ... @@ -8,7 +8,37 @@
8 8 #include "Arduino.h"
9 9 #include "Wire.h"
10 10  
11   -#define DEFAULT_ADDRESS byte(0xC6)
  11 +// Commands LCD05
  12 +
  13 +#define COMMAND byte(0)
  14 +#define CURSOR_HOME byte(1)
  15 +#define SET_CURSOR byte(2)
  16 +#define SET_CURSOR_COORDS byte(3)
  17 +#define HIDE_CURSOR byte(4)
  18 +#define SHOW_UNDERLINE_CURSOR byte(5)
  19 +#define SHOW_BLINKING_CURSOR byte(6)
  20 +#define BACKSPACE byte(8)
  21 +#define HORIZONTAL_TAB byte(9)
  22 +#define SMART_LINE_FEED byte(10)
  23 +#define VERTICAL_TAB byte(11)
  24 +#define CLEAR_SCREEN byte(12)
  25 +#define CARRIAGE_RETURN byte(13)
  26 +#define CLEAR_COLUMN byte(17)
  27 +#define TAB_SET byte(18)
  28 +#define BACKLIGHT_ON byte(19)
  29 +#define BACKLIGHT_OFF byte(20)
  30 +#define DISABLE_STARTUP_MESSAGE byte(21)
  31 +#define ENABLE_STARTUP_MESSAGE byte(22)
  32 +#define SAVE_AS_STARTUP_SCREEN byte(23)
  33 +#define SET_DISPLAY_TYPE byte(24)
  34 +#define CHANGE_ADDRESS byte(25)
  35 +#define CUSTOM_CHAR_GENERATOR byte(27)
  36 +#define DOUBLE_KEYPAD_SCAN_RATE byte(28)
  37 +#define NORMAL_KEYPAD_SCAN_RATE byte(29)
  38 +#define CONTRAST_SET byte(30)
  39 +#define BRIGHTNESS_SET byte(31)
  40 +
  41 +#define DEFAULT_ADDRESS byte(0xC6)
12 42  
13 43 class LCD {
14 44 public:
... ... @@ -17,7 +47,9 @@ class LCD {
17 47 private:
18 48 byte lcd_addr;
19 49  
20   - setup();
  50 + void lcd_setup();
  51 + void command(byte cmd);
  52 + void backlight(bool state);
21 53 };
22 54  
23 55 #endif
... ...
tests/LCD/src/main.c
... ... @@ -1,7 +0,0 @@
1   -#include "LCD.h"
2   -
3   -LCD lcd(0xCE);
4   -
5   -void setup() {}
6   -
7   -void loop() {}
tests/LCD/src/main.cpp 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +#include "LCD.h"
  2 +
  3 +LCD lcd;
  4 +
  5 +void setup() {}
  6 +
  7 +void loop() {}
... ...