/
hwconfig.h
188 lines (167 loc) · 5.96 KB
/
hwconfig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#define Use_SoftI2CMaster
//#define Use_SoftWire
#define I2CFAST
#if defined(I2CFAST)
#define I2C_FASTMODE 1
#define I2CCLOCK 400000L //100000L for StandarMode, 400000L for FastMode and 1000000L for FastModePlus
#else
#define I2C_FASTMODE 0
#define I2CCLOCK 100000L //100000L for StandarMode, 400000L for FastMode and 1000000L for FastModePlus
#endif
// default SPI clock speed
#ifndef SD_SPI_CLOCK_SPEED
#if defined(ESP32) || defined(ESP8266)
#ifndef SD_SPI_CLOCK_SPEED
#define SD_SPI_CLOCK_SPEED SD_SCK_MHZ(4)
#endif
#endif
#ifndef SD_SPI_CLOCK_SPEED
#define SD_SPI_CLOCK_SPEED SPI_FULL_SPEED
#endif
#endif
#if defined(__AVR_ATmega4809__) || defined (__AVR_ATmega4808__)
#ifdef Use_SoftI2CMaster
#undef Use_SoftI2CMaster
//#error This chip does not support SoftI2CMaster. Please undefine Use_SoftI2CMaster
#endif
#ifdef Use_SoftWire
#undef Use_SoftWire
//#error This chip does not support Softwire. Please undefine Use_SoftWire
#endif
//
// PATCH PROCERURE NEEDED FOR NANO EVERY AND THINARY TO SWAP TIMERS AND AVOID HANGING
//
// In C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.4
// change .\variants\nona4809\timers.h , .\variants\nona4809\variant.c , .\cores\arduino\wiring.c
//
// In C:\Users\Rafael\AppData\Local\Arduino15\packages\thinary\hardware\avr\1.0.0
// change .\variants\nona4808\timers.h , .\variants\nona4808\variant.c , .\cores\arduino\wiring.c
//
// Needs 2 patches, check your version:
//
// SDFat 20150201 (old and very slow):
// 1. In SdFatConfig.h change line 84 #define SD_SPI_CONFIGURATION 0
// with: #define SD_SPI_CONFIGURATION 1
// 2. In SdSpi.h change line 292 #ifdef __AVR__
// with: #if defined(__AVR__) && not defined(__AVR_ATmega4809__)&& not defined(__AVR_ATmega4808__)
//
// SDFat 1.1.0 (faster and recommended):
// 1. In SdFatConfig.h change line 216 #elif defined(__AVR__)\
// with: #elif defined(__AVR__) && not defined(__AVR_ATmega4809__)&& not defined(__AVR_ATmega4808__)\
//
// 2. In SpiDriver/SdSpiDriver.h change line 374 #ifdef __AVR__
// with: #if defined(__AVR__) && not defined(__AVR_ATmega4809__)&& not defined(__AVR_ATmega4808__)
//#define TimerOne
#elif defined(__arm__) && defined(__STM32F1__)
#ifdef Use_SoftI2CMaster
#undef Use_SoftI2CMaster
#endif
#ifdef Use_SoftWire
#undef Use_SoftWire
#endif
//#define TimerOne
#elif defined(__SAMD21__) || defined(ESP32) || defined(ESP8266)
#ifdef Use_SoftI2CMaster
#undef Use_SoftI2CMaster
#endif
#ifdef Use_SoftWire
#undef Use_SoftWire
#endif
#elif defined(__AVR_ATmega2560__)
//#define TimerOne
#elif defined(__AVR_ATmega32U4__)
//#undef Use_SoftI2CMaster
//#undef Use_SoftWire
//#undef I2CFAST
#elif defined(__AVR_ATmega328P__)
//#define TimerOne
#else
#error I2C definitions (SoftI2CMaster/SoftWire/etc) not defined for board
#endif
#ifdef TimerOne
#include <TimerOne.h>
const TimerOne &Timer = Timerl;
#else
#include "TimerCounter.h"
#endif
#if defined(__arm__) && defined(__STM32F1__)
#include <itoa.h>
#define strncpy_P(a, b, n) strncpy((a), (b), (n))
#define memcmp_P(a, b, n) memcmp((a), (b), (n))
#define strcasecmp_P(a,b) strcasecmp((a), (b))
#endif
#include <SdFat.h>
#define scrollSpeed 250 //text scroll delay
#define scrollWait 3000 //Delay before scrolling starts
#ifdef LCDSCREEN16x2
//#include <Wire.h>
#include "LiquidCrystal_I2C_Soft.h"
LiquidCrystal_I2C lcd(LCD_I2C_ADDR,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#define SCREENSIZE 16
#elif defined(OLED1306)
#if defined(Use_SoftI2CMaster) && defined(__AVR_ATmega2560__)
#define SDA_PORT PORTD
#define SDA_PIN 1
#define SCL_PORT PORTD
#define SCL_PIN 0
#include <SoftI2CMaster.h>
#elif defined(Use_SoftI2CMaster) && defined(__AVR_ATmega32U4__)
#define SDA_PORT PORTD
#define SDA_PIN 1
#define SCL_PORT PORTD
#define SCL_PIN 0
#include <SoftI2CMaster.h>
#elif defined(Use_SoftI2CMaster)
#define SDA_PORT PORTC
#define SDA_PIN 4
#define SCL_PORT PORTC
#define SCL_PIN 5
#include <SoftI2CMaster.h>
#elif defined(Use_SoftWire) && defined(__AVR_ATmega2560__)
#define SDA_PORT PORTD
#define SDA_PIN 1
#define SCL_PORT PORTD
#define SCL_PIN 0
#include <SoftWire.h>
SoftWire Wire = SoftWire();
#elif defined(Use_SoftWire) && defined(__AVR_ATmega32U4__)
#define SDA_PORT PORTD
#define SDA_PIN 1
#define SCL_PORT PORTD
#define SCL_PIN 0
#include <SoftWire.h>
SoftWire Wire = SoftWire();
#elif defined(Use_SoftWire)
#define SDA_PORT PORTC
#define SDA_PIN 4
#define SCL_PORT PORTC
#define SCL_PIN 5
#include <SoftWire.h>
SoftWire Wire = SoftWire();
#else
#include <Wire.h>
#endif
#define SCREENSIZE 16
#elif defined(P8544)
#include <pcd8544.h>
#define ADMAX 1023
#define ADPIN 0
#include <avr/pgmspace.h>
byte dc_pin = 5;
byte reset_pin = 3;
byte cs_pin = 4;
pcd8544 lcd(dc_pin, reset_pin, cs_pin);
#define backlight_pin 2
#define SCREENSIZE 14
const byte Play [] PROGMEM = {
0x00, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00
};
const byte Paused [] PROGMEM = {
0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00
};
const byte Stop [] PROGMEM = {
0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e
};
#else
#define SCREENSIZE 16
#endif