Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added FEATURE_LCD_ST7032 For 7032 based i2c Display #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions k3ng_keyer/k3ng_keyer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,8 @@ Recent Update History
2021.12.17.01
Merged pull request 119 https://github.com/k3ng/k3ng_cw_keyer/pull/119/ Definable startup text (define HI_TEXT) - Thanks, ON6ZQ

2022.03.07 GM0HYY version to add St7032 LCD via I2C

Documentation: https://github.com/k3ng/k3ng_cw_keyer/wiki

Support: https://groups.io/g/radioartisan ( Please do not email K3NG directly for support. Thanks )
Expand Down Expand Up @@ -1610,6 +1612,10 @@ If you offer a hardware kit using this software, show your appreciation by sendi
#include "SSD1306AsciiWire.h"
#endif

#if defined(FEATURE_LCD_ST7032)
#include <ST7032_asukiaaa.h>
#endif

#if defined(FEATURE_TRAINING_COMMAND_LINE_INTERFACE)
// #include <BasicTerm.h>
#endif
Expand Down Expand Up @@ -2052,6 +2058,10 @@ byte send_buffer_status = SERIAL_SEND_BUFFER_NORMAL;
SSD1306AsciiWire lcd;
#endif

#if defined(FEATURE_LCD_ST7032)
ST7032_asukiaaa lcd;
#endif

#if defined(FEATURE_USB_KEYBOARD) || defined(FEATURE_USB_MOUSE)
USB Usb;
uint32_t next_time;
Expand Down Expand Up @@ -18366,6 +18376,11 @@ void initialize_display(){
lcd.begin(LCD_COLUMNS, LCD_ROWS);
#endif
#endif

#ifdef FEATURE_LCD_ST7032
lcd.begin(LCD_COLUMNS, LCD_ROWS); // columns and rows
lcd.setContrast(30);
#endif

#ifdef FEATURE_LCD_ADAFRUIT_I2C
lcd.setBacklight(lcdcolor);
Expand Down
4 changes: 2 additions & 2 deletions k3ng_keyer/keyer_dependencies.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#if defined(FEATURE_LCD_4BIT) || defined(FEATURE_LCD_8BIT) || defined(FEATURE_LCD_ADAFRUIT_I2C) || defined(FEATURE_LCD_ADAFRUIT_BACKPACK) || defined(FEATURE_LCD_YDv1) ||defined(FEATURE_LCD1602_N07DH) || defined(FEATURE_LCD_SAINSMART_I2C) || defined(FEATURE_LCD_FABO_PCF8574) || defined(FEATURE_LCD_MATHERTEL_PCF8574) || defined(FEATURE_LCD_HD44780) || defined(FEATURE_LCD_I2C_FDEBRABANDER) || defined(FEATURE_LCD_TWILIQUIDCRYSTAL) || defined(FEATURE_OLED_SSD1306)
#define FEATURE_DISPLAY
#if defined(FEATURE_LCD_4BIT) || defined(FEATURE_LCD_ST7032) || defined(FEATURE_LCD_8BIT) || defined(FEATURE_LCD_ADAFRUIT_I2C) || defined(FEATURE_LCD_ADAFRUIT_BACKPACK) || defined(FEATURE_LCD_YDv1) || defined(FEATURE_LCD1602_N07DH) || defined(FEATURE_LCD_SAINSMART_I2C) || defined(FEATURE_LCD_FABO_PCF8574) || defined(FEATURE_LCD_MATHERTEL_PCF8574) || defined(FEATURE_LCD_HD44780) || defined(FEATURE_LCD_I2C_FDEBRABANDER) || defined(FEATURE_LCD_TWILIQUIDCRYSTAL) || defined(FEATURE_OLED_SSD1306)
#define FEATURE_DISPLAY
#endif

#if defined(FEATURE_COMMAND_LINE_INTERFACE_ON_SECONDARY_PORT) && !defined(FEATURE_COMMAND_LINE_INTERFACE)
Expand Down
11 changes: 6 additions & 5 deletions k3ng_keyer/keyer_features_and_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// #define FEATURE_BUTTONS
// #define FEATURE_COMMAND_MODE
// #define FEATURE_COMMAND_LINE_INTERFACE // Command Line Interface functionality
#define FEATURE_COMMAND_LINE_INTERFACE // Command Line Interface functionality
// #define FEATURE_MEMORIES // on the Arduino Due, you must have FEATURE_EEPROM_E24C1024 and E24C1024 EEPROM hardware in order to compile this
// #define FEATURE_MEMORY_MACROS
// #define FEATURE_WINKEY_EMULATION // disabling Automatic Software Reset is highly recommended (see documentation)
Expand All @@ -14,7 +14,7 @@
// #define FEATURE_POTENTIOMETER // do not enable unless you have a potentiometer connected, otherwise noise will falsely trigger wpm changes
// #define FEATURE_SIDETONE_SWITCH // adds switch control for the sidetone output. requires an external toggle switch (assigned to an arduino pin - see keyer_pin_settings.h).
// #define FEATURE_SIDETONE_NEWTONE // Use the NewTone library, ~1k smaller code size than the standard tone library. Uses timer1 (pins 9 or 10) https://bitbucket.org/teckel12/arduino-new-tone/wiki/Home
// #define FEATURE_SERIAL_HELP
#define FEATURE_SERIAL_HELP
// #define FEATURE_HELL // Hellscreiber Mode
// #define FEATURE_PS2_KEYBOARD // Use a PS2 keyboard to send code - Change keyboard layout (non-US) in K3NG_PS2Keyboard.h. Additional options below.
// #define FEATURE_USB_KEYBOARD // Use a USB keyboard to send code - Uncomment three lines in k3ng_keyer.ino (search for note_usb_uncomment_lines)
Expand All @@ -35,6 +35,7 @@
// #define FEATURE_LCD_MATHERTEL_PCF8574 // https://github.com/mathertel/LiquidCrystal_PCF8574
// #define FEATURE_LCD_I2C_FDEBRABANDER // https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
// #define FEATURE_LCD_HD44780
#define FEATURE_LCD_ST7032 //uses library https://github.com/asukiaaa/ST7032_asukiaaa added GM0HYY
// #define FEATURE_OLED_SSD1306 // https://github.com/greiman/SSD1306Ascii
// #define FEATURE_CW_DECODER // https://github.com/k3ng/k3ng_cw_keyer/wiki/385-Feature:-CW-Decoder
// #define FEATURE_SLEEP // go to sleep after x minutes to conserve battery power (not compatible with Arduino DUE, may have mixed results with Mega and Mega ADK)
Expand All @@ -49,10 +50,10 @@
// #define FEATURE_PTT_INTERLOCK
// #define FEATURE_QLF
// #define FEATURE_EEPROM_E24C1024
// #define FEATURE_STRAIGHT_KEY
#define FEATURE_STRAIGHT_KEY
// #define FEATURE_DYNAMIC_DAH_TO_DIT_RATIO
// #define FEATURE_PADDLE_ECHO // you may also need to comment out line 19 in the file keyer_dependencies.h
// #define FEATURE_STRAIGHT_KEY_ECHO
#define FEATURE_PADDLE_ECHO // you may also need to comment out line 19 in the file keyer_dependencies.h
#define FEATURE_STRAIGHT_KEY_ECHO
// #define FEATURE_AMERICAN_MORSE
// #define FEATURE_4x4_KEYPAD // code contributed by Jack, W0XR - documentation: https://github.com/k3ng/k3ng_cw_keyer/wiki/380-Feature:-Keypad
// #define FEATURE_3x4_KEYPAD // code contributed by Jack, W0XR - documentation: https://github.com/k3ng/k3ng_cw_keyer/wiki/380-Feature:-Keypad
Expand Down
2 changes: 1 addition & 1 deletion k3ng_keyer/keyer_pin_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ FEATURE_SIDETONE_SWITCH
#endif //FEATURE_PTT_INTERLOCK

#ifdef FEATURE_STRAIGHT_KEY
#define pin_straight_key 52
#define pin_straight_key 3 //was 52 jjt
#endif //FEATURE_STRAIGHT_KEY

// FEATURE_CW_DECODER & OPTION_CW_DECODER_GOERTZEL_AUDIO_DETECTOR
Expand Down
82 changes: 82 additions & 0 deletions libraries/ST7032_asukiaaa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# ST7032_asukiaaa

A library to control ST7032 on a LiquidCrystal.
This library was forked from [tomozh/arduino_ST7032](https://github.com/tomozh/arduino_ST7032).

# Install

## Arduino IDE
You can install via library manager.
Search `ST7032` on the library manager

## PlatformIO

Add this library to dependencies on `platformio.ini`.
```
lib_deps =
ST7032_asukiaaa
```

# Connection

ST7032 | Arduino
-------|--------
VDD | 3V3
RES | 3V3
SDA* | SDA(A4 for Uno)
SCL* | SCL(A5 for Uno)
GND | GND

*... 10Kohm pull-up is needed.

You can check SDA and SCL for your board on [Wire page](https://www.arduino.cc/en/reference/wire).

# Usage

## Hello world
See [HelloWorld](./examples/HelloWorld/HelloWorld.ino).

```c
#include <ST7032_asukiaaa.h>

ST7032_asukiaaa lcd;

void setup() {
lcd.begin(16, 2); // LCD columns and rows.
lcd.setContrast(40);
// If lcd become black, reduced value for contrast
// lcd.setContrast(10);
lcd.print("hello, world!");
}

void loop() {
lcd.setCursor(0, 1);
lcd.print(millis()/1000);
}
```

## Set slave address
You can specify slave address for a LCD.

```c
ST7032_asukiaaa lcd(0x3E);
```

## Set wire
You can set customized wire.(See [setWire](./examples/setWire/setWire.ino))

```c
#if defined(ESP32)
Wire.begin(25, 26); // SDA, SCL
lcd.setWire(&Wire);
#endif
```

See [examples](./examples) to know other usage.

# License
MIT

# References
- [I2C液晶のArduinoライブラリ – ST7032](http://ore-kb.net/archives/195)
- [tomozh/arduino_ST7032](https://github.com/tomozh/arduino_ST7032)
18 changes: 18 additions & 0 deletions libraries/ST7032_asukiaaa/examples/HelloWorld/HelloWorld.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <ST7032_asukiaaa.h>

ST7032_asukiaaa lcd;

void setup() {
lcd.begin(16, 2); // columns and rows

lcd.setContrast(30);
// If lcd become black, try reduced value for contrast
// lcd.setContrast(10);

lcd.print("hello!");
}

void loop() {
lcd.setCursor(0, 1);
lcd.print(millis()/1000);
}
85 changes: 85 additions & 0 deletions libraries/ST7032_asukiaaa/examples/Icon/Icon.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
ST7032 I2C LCD Controler - Icon Display Example
2013/05/11 [email protected]

------------------------
Arduino ST7032
------------------------
3.3V --+-- VDD
+-- RST
A4(SDA) --*-- SDA
A5(SCL) --*-- SCL
GND ----- GND

*... 10Kohm pull-up
------------------------
*/

#include <ST7032_asukiaaa.h>


#define NELEMS(arg) (sizeof(arg) / sizeof((arg)[0]))

typedef struct tagICON_MAP {
byte addr;
byte pat;
}ICON_MAP;

static const ICON_MAP iconMap[] = {
{ 0x00, (1<<4) }, // 0
{ 0x02, (1<<4) }, // 1
{ 0x04, (1<<4) }, // 2
{ 0x06, (1<<4) }, // 3
{ 0x07, (1<<4) }, // 4
{ 0x07, (1<<3) }, // 5
{ 0x09, (1<<4) }, // 6
{ 0x0B, (1<<4) }, // 7
{ 0x0D, (1<<4) }, // 8
{ 0x0D, (1<<3) }, // 9
{ 0x0D, (1<<2) }, // 10
{ 0x0D, (1<<1) }, // 11
{ 0x0F, (1<<4) }, // 12
};

static byte iconTmp[16];
bool showIcon = true;
ST7032_asukiaaa lcd;

static void setIndexedIcon(uint8_t index, bool show) {
if((0 <= index) && (index < NELEMS(iconMap))) {
const ICON_MAP* pMap = &iconMap[index];
byte* pTmp = &iconTmp[pMap->addr];

if(show) {
*pTmp |= pMap->pat;
} else {
*pTmp &= ~pMap->pat;
}

lcd.setIcon(pMap->addr, *pTmp);
}
}

void setup(){
lcd.begin(16, 2, LCD_5x8DOTS);
lcd.setContrast(30);
lcd.print("ST7032 ICON TEST");
}

void loop(){
int i;

for(i = 0; i < NELEMS(iconMap); i++) {
setIndexedIcon(i, showIcon);
lcd.setCursor(0, 1);
lcd.print("No.");
lcd.print(i);
lcd.print(" ");

delay(500);
}

while(1){}

showIcon = !showIcon;
}
18 changes: 18 additions & 0 deletions libraries/ST7032_asukiaaa/examples/setWire/setWire.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <ST7032_asukiaaa.h>

ST7032_asukiaaa lcd;

void setup() {
#if defined(ESP32)
Wire.begin(21, 22); // SDA, SCL
lcd.setWire(&Wire);
#endif
lcd.begin(16, 2);
lcd.setContrast(30);
lcd.print("hello, world!");
}

void loop() {
lcd.setCursor(0, 1);
lcd.print(millis()/1000);
}
43 changes: 43 additions & 0 deletions libraries/ST7032_asukiaaa/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#######################################
# Syntax Coloring Map For ST7032
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

ST7032_asukiaaa KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

autoscroll KEYWORD2
begin KEYWORD2
blink KEYWORD2
clear KEYWORD2
command KEYWORD2
createChar KEYWORD2
cursor KEYWORD2
display KEYWORD2
home KEYWORD2
leftToRight KEYWORD2
noAutoscroll KEYWORD2
noBlink KEYWORD2
noCursor KEYWORD2
noDisplay KEYWORD2
rightToLeft KEYWORD2
scrollDisplayLeft KEYWORD2
scrollDisplayRight KEYWORD2
setContrast KEYWORD2
setCursor KEYWORD2
setIcon KEYWORD2
setWire KEYWORD2

######################################
# Instances (KEYWORD2)
#######################################

#######################################
# Constants (LITERAL1)
#######################################
10 changes: 10 additions & 0 deletions libraries/ST7032_asukiaaa/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name=ST7032_asukiaaa
version=1.0.5
author=tomozh <[email protected]>, Asuki Kono <[email protected]>
maintainer=Asuki Kono <[email protected]>
sentence=This library controls ST7032 on LCD.
paragraph=This library can control LCDs that using ST7032. Ex: SB1602B, SB0802G, AQM0802A-RN-GBW, AQM1602 and so on.
category=Display
url=https://github.com/asukiaaa/ST7032_asukiaaa
architectures=*
includes=ST7032_asukiaaa.h
Loading