|
@ -36,11 +36,61 @@ |
|
|
// Optimize this code with -O3
|
|
|
// Optimize this code with -O3
|
|
|
#pragma GCC optimize (3) |
|
|
#pragma GCC optimize (3) |
|
|
|
|
|
|
|
|
|
|
|
#ifndef ST7920_DELAY_1 |
|
|
|
|
|
#ifndef LCD_ST7920_DELAY_1 |
|
|
|
|
|
#define LCD_ST7920_DELAY_1 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef BOARD_ST7920_DELAY_1 |
|
|
|
|
|
#define BOARD_ST7920_DELAY_1 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef CPU_ST7920_DELAY_1 |
|
|
|
|
|
#define CPU_ST7920_DELAY_1 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#if LCD_ST7920_DELAY_1 || BOARD_ST7920_DELAY_1 || CPU_ST7920_DELAY_1 |
|
|
|
|
|
#define ST7920_DELAY_1 DELAY_NS(_MAX(LCD_ST7920_DELAY_1, BOARD_ST7920_DELAY_1, CPU_ST7920_DELAY_1)) |
|
|
|
|
|
#else |
|
|
|
|
|
#define ST7920_DELAY_1 |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef ST7920_DELAY_2 |
|
|
|
|
|
#ifndef LCD_ST7920_DELAY_2 |
|
|
|
|
|
#define LCD_ST7920_DELAY_2 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef BOARD_ST7920_DELAY_2 |
|
|
|
|
|
#define BOARD_ST7920_DELAY_2 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef CPU_ST7920_DELAY_2 |
|
|
|
|
|
#define CPU_ST7920_DELAY_2 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#if LCD_ST7920_DELAY_2 || BOARD_ST7920_DELAY_2 || CPU_ST7920_DELAY_2 |
|
|
|
|
|
#define ST7920_DELAY_2 DELAY_NS(_MAX(LCD_ST7920_DELAY_2, BOARD_ST7920_DELAY_2, CPU_ST7920_DELAY_2)) |
|
|
|
|
|
#else |
|
|
|
|
|
#define ST7920_DELAY_2 |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef ST7920_DELAY_3 |
|
|
|
|
|
#ifndef LCD_ST7920_DELAY_3 |
|
|
|
|
|
#define LCD_ST7920_DELAY_3 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef BOARD_ST7920_DELAY_3 |
|
|
|
|
|
#define BOARD_ST7920_DELAY_3 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef CPU_ST7920_DELAY_3 |
|
|
|
|
|
#define CPU_ST7920_DELAY_3 0 |
|
|
|
|
|
#endif |
|
|
|
|
|
#if LCD_ST7920_DELAY_3 || BOARD_ST7920_DELAY_3 || CPU_ST7920_DELAY_3 |
|
|
|
|
|
#define ST7920_DELAY_3 DELAY_NS(_MAX(LCD_ST7920_DELAY_3, BOARD_ST7920_DELAY_3, CPU_ST7920_DELAY_3)) |
|
|
|
|
|
#else |
|
|
|
|
|
#define ST7920_DELAY_3 |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#ifdef ARDUINO_ARCH_STM32F1 |
|
|
#ifdef ARDUINO_ARCH_STM32F1 |
|
|
#define ST7920_DAT(V) !!((V) & 0x80) |
|
|
#define ST7920_DAT(V) !!((V) & 0x80) |
|
|
#else |
|
|
#else |
|
|
#define ST7920_DAT(V) ((V) & 0x80) |
|
|
#define ST7920_DAT(V) ((V) & 0x80) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#define ST7920_SND_BIT do{ \ |
|
|
#define ST7920_SND_BIT do{ \ |
|
|
WRITE(ST7920_CLK_PIN, LOW); ST7920_DELAY_1; \ |
|
|
WRITE(ST7920_CLK_PIN, LOW); ST7920_DELAY_1; \ |
|
|
WRITE(ST7920_DAT_PIN, ST7920_DAT(val)); ST7920_DELAY_2; \ |
|
|
WRITE(ST7920_DAT_PIN, ST7920_DAT(val)); ST7920_DELAY_2; \ |
|
|