Compare commits
29
Commits
bb0675b8a3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
780d52c8d8
|
||
|
|
731f69ffa1
|
||
|
|
bd094dc978
|
||
|
|
5a1a84f431
|
||
|
|
562427df20
|
||
|
|
9e5bddccfa
|
||
|
|
c770decab7
|
||
|
|
63c7bd5640
|
||
|
|
c1164145e9
|
||
|
|
eaaae92fe3
|
||
|
|
1aa495bc3e
|
||
|
|
c327c7d9d0
|
||
|
|
ebeb452ded
|
||
|
|
015079b151
|
||
|
|
d1294914ce
|
||
|
|
9e6cf2bd72
|
||
|
|
21fd8d00ec
|
||
|
|
9cf4593517
|
||
|
|
140f88d371
|
||
|
|
ae194ed052
|
||
|
|
57aa865b2b
|
||
|
|
af0e177c7d
|
||
|
|
01aa31a1fa
|
||
|
|
5e6371b409
|
||
|
|
d79358fa48
|
||
|
|
8d5e41846b
|
||
|
|
f5c810f42e
|
||
|
|
3668854cd4
|
||
|
|
2d03316910
|
@@ -0,0 +1,317 @@
|
|||||||
|
# PC Control Interface
|
||||||
|
|
||||||
|
The PC Control Interface of the firmware allows the PC to do useful things with the radio directly.
|
||||||
|
|
||||||
|
## Invoking
|
||||||
|
|
||||||
|
Any time, ever, the PC ("Serial device") can send a "~/" on the data line, once the radio is ready for command (or already is), a response will get received: [0x01 0xFF].
|
||||||
|
|
||||||
|
That means, we can send commands to the radio now.
|
||||||
|
|
||||||
|
## Packet
|
||||||
|
|
||||||
|
Every single packet starts with its length (MSB of length is reserved for optional CRC8 at end of packet, see [CRC](#crc)), example: [0x02 0xAA 0x55] [0x03 0x00 0x01 0x02]
|
||||||
|
|
||||||
|
The byte after the lenght is expected to be the command, which will be defined below
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### 0 - Set clock
|
||||||
|
|
||||||
|
This sets the I2C clock.
|
||||||
|
|
||||||
|
4 bytes after command should represent the clock to set as commanded.
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
Set clock to 400 kHz
|
||||||
|
|
||||||
|
[0x05] - Length
|
||||||
|
|
||||||
|
[0x00] - Command
|
||||||
|
|
||||||
|
[0x00] - MSB Byte of clock value
|
||||||
|
|
||||||
|
[0x06]
|
||||||
|
|
||||||
|
[0x1A]
|
||||||
|
|
||||||
|
[0x80] - LSB Byte of the clock value
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0x00] - Response to command 0
|
||||||
|
|
||||||
|
#### 1 - Send I2C data
|
||||||
|
|
||||||
|
This command sends out the provided data to a provided address over I2C
|
||||||
|
|
||||||
|
First byte after the command should be the address, and the rest until the end of the command shall be the data itself
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
|
||||||
|
[0x03] - Length
|
||||||
|
|
||||||
|
[0x01] - Command
|
||||||
|
|
||||||
|
[X] - Device address
|
||||||
|
|
||||||
|
[X] - Address to set on the device (data)
|
||||||
|
|
||||||
|
[X] - Address contents on the device (data)
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x02] - Length
|
||||||
|
|
||||||
|
[0x01] - Response to command 0
|
||||||
|
|
||||||
|
[X] - Arbitrary status value which matches the value of Arduino's endTransmission function
|
||||||
|
|
||||||
|
#### 2 - Send + Receive I2C data
|
||||||
|
|
||||||
|
This command sends out the provided data to a provided address over I2C, but then sends a repeated start and requests a number of bytes which is provided by the command
|
||||||
|
|
||||||
|
First byte after the command should be the address, the following byte should be the lenght of the data to send before reading, the message that is to be send should be sent now, and the last byte should be the number of bytes to receive from the device
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
[0x03] - Length
|
||||||
|
|
||||||
|
[0x02] - Command
|
||||||
|
|
||||||
|
[X] - Device address
|
||||||
|
|
||||||
|
[X] - Length of data to send
|
||||||
|
|
||||||
|
[X] - Actual data
|
||||||
|
|
||||||
|
[n] - Request two bytes from the device
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x02+n] - Length
|
||||||
|
|
||||||
|
[0x02] - Response to command 2
|
||||||
|
|
||||||
|
[X] - Arbitrary status value which matches the value of Arduino's endTransmission function
|
||||||
|
|
||||||
|
n*[X] - Data received from the device
|
||||||
|
|
||||||
|
#### 3 - Quit
|
||||||
|
|
||||||
|
This commands quits the control interface.
|
||||||
|
|
||||||
|
It will also reset the baud rate to 115200
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0x03] - Command
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0x03] - Response to command 3
|
||||||
|
|
||||||
|
#### 4 - Protocol version
|
||||||
|
|
||||||
|
Returns the current protocol version
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0x04] - Command
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x02] - Length
|
||||||
|
|
||||||
|
[0x04] - Response to command 4
|
||||||
|
|
||||||
|
[0x03] - Current protocol version
|
||||||
|
|
||||||
|
#### 5 - Reboot
|
||||||
|
|
||||||
|
This command will reset the ESP32
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0x05] - Command
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0x05] - Response to command 5
|
||||||
|
|
||||||
|
#### 6 - Change baud rate
|
||||||
|
|
||||||
|
This will change the baud rate. Response of this command is still in the prev baud rate.
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
Set baud rate to 921600
|
||||||
|
|
||||||
|
[0x05] - Length
|
||||||
|
|
||||||
|
[0x06] - Command
|
||||||
|
|
||||||
|
[0x00] - MSB byte of baud rate
|
||||||
|
|
||||||
|
[0x0E]
|
||||||
|
|
||||||
|
[0x10]
|
||||||
|
|
||||||
|
[0x00] - LSB byte of baud rate
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0x06] - Response to command 6
|
||||||
|
|
||||||
|
#### 7 - Write to EEPROM
|
||||||
|
|
||||||
|
This command will write to the NVS of the ESP32
|
||||||
|
|
||||||
|
This command is only available on versions 2+
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
Store 0xff at address 0x10
|
||||||
|
|
||||||
|
[0x04] - Length
|
||||||
|
|
||||||
|
[0x07] - Command
|
||||||
|
|
||||||
|
[0x00] - MSB byte of address
|
||||||
|
|
||||||
|
[0x10] - LSB byte of address
|
||||||
|
|
||||||
|
[0xff]
|
||||||
|
|
||||||
|
Store 0xffaa at address 0x5555
|
||||||
|
|
||||||
|
[0x04] - Length
|
||||||
|
|
||||||
|
[0x07] - Command
|
||||||
|
|
||||||
|
[0x55] - MSB byte of address
|
||||||
|
|
||||||
|
[0x55] - LSB byte of address
|
||||||
|
|
||||||
|
[0xff]
|
||||||
|
|
||||||
|
[0xaa]
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0x07] - Response to command 7
|
||||||
|
|
||||||
|
#### 8 - Read from EEPROM
|
||||||
|
|
||||||
|
This command will read from the NVS of the ESP32
|
||||||
|
|
||||||
|
This command is only available on versions 2+
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
|
||||||
|
[0x04] - Length
|
||||||
|
|
||||||
|
[0x08] - Command
|
||||||
|
|
||||||
|
[X] - MSB byte of address
|
||||||
|
|
||||||
|
[X] - LSB byte of address
|
||||||
|
|
||||||
|
[n] - Length to read
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x01 + n] - Length
|
||||||
|
|
||||||
|
[0x08] - Response to command 8
|
||||||
|
|
||||||
|
n*[X] - Data read from EEPROM
|
||||||
|
|
||||||
|
#### 253 - Get user data for control mode
|
||||||
|
|
||||||
|
This command is only available on versions 2+
|
||||||
|
|
||||||
|
This commands gets the length and address of the user data for control mode
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0xFD] - Command
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x05] - Length
|
||||||
|
|
||||||
|
[0xFD] - Response to command 253
|
||||||
|
|
||||||
|
[X] - MSB byte of address
|
||||||
|
|
||||||
|
[X] - LSB byte of address
|
||||||
|
|
||||||
|
[X] - MSB byte of size
|
||||||
|
|
||||||
|
[X] - LSB byte of size
|
||||||
|
|
||||||
|
#### 254 - Get persistence address
|
||||||
|
|
||||||
|
This command is only available on versions 2+
|
||||||
|
|
||||||
|
If an non zero was written to the persistance address in the EEPROM, after every reboot the radio would boot up into the control mode without the full init sequence (Holding mode while booting will override this)
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0xFE] - Command
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x03] - Length
|
||||||
|
|
||||||
|
[0xFE] - Response to command 254
|
||||||
|
|
||||||
|
[X] - MSB byte of persistence address
|
||||||
|
|
||||||
|
[X] - LSB byte of persistence address
|
||||||
|
|
||||||
|
#### 255 - Ping / Wake
|
||||||
|
|
||||||
|
This command is only available on versions 2+
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0xFF] - Command
|
||||||
|
|
||||||
|
##### Response
|
||||||
|
|
||||||
|
[0x01] - Length
|
||||||
|
|
||||||
|
[0xFF] - Response to command 255
|
||||||
|
|
||||||
|
### CRC
|
||||||
|
|
||||||
|
First bit of the length from version 3 control whether there is an crc byte at the end of the command, it is not included in the length. If the request was sent with CRC, response also will be too. In case of a CRC mismatch the radio will send back [0x02 0xFF 0x01]. CRC is calculated with the lenght included
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
Length is now 16 bits. MSB is now the last bit of the 16 bits.
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 8.9 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.9 MiB |
@@ -0,0 +1 @@
|
|||||||
|
Sorry for the bad quality, but no one asked for photos, so you still should congratulate me for them
|
||||||
+4
-3
@@ -2,10 +2,11 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "rtc.hpp"
|
#include "rtc.hpp"
|
||||||
|
|
||||||
static const char ntpServerName[] = "0.pool.ntp.org";
|
static constexpr char ntpServerName[] = "0.pool.ntp.org";
|
||||||
static const int localPort = 8944;
|
static constexpr int localPort = 8944;
|
||||||
const int NTP_PACKET_SIZE = 48;
|
constexpr int NTP_PACKET_SIZE = 48;
|
||||||
|
|
||||||
void sendNTPpacket(IPAddress &address);
|
void sendNTPpacket(IPAddress &address);
|
||||||
void NTPupdate();
|
void NTPupdate();
|
||||||
time_t getNtpTime();
|
time_t getNtpTime();
|
||||||
|
void ntpPoll();
|
||||||
+32
-32
@@ -100,14 +100,14 @@ static const uint16_t oda_app_ids[] {
|
|||||||
|
|
||||||
static const char* const ECCtext[] {
|
static const char* const ECCtext[] {
|
||||||
"Bundesrepublik Deutschland", // 0
|
"Bundesrepublik Deutschland", // 0
|
||||||
"Ελληνική Δημοκρατία / (Hellenic Republic)", // 1
|
"Ελληνική Δημοκρατία [Hellenic Republic]", // 1
|
||||||
"Kingdom of Morroco", // 2
|
"Kingdom of Morroco", // 2
|
||||||
"Republica Moldova", // 3
|
"Republica Moldova", // 3
|
||||||
"People's Democratic Republic of Algeria", // 4
|
"People's Democratic Republic of Algeria", // 4
|
||||||
"Κυπριακή Δημοκρατία / (Republic of Cyprus)", // 5
|
"Κυπριακή Δημοκρατία [Republic of Cyprus]", // 5
|
||||||
"Česká republika", // 6
|
"Česká republika", // 6
|
||||||
"Ireland", // 7
|
"Ireland", // 7
|
||||||
"Eesti Vabariik / (Republic of Estonia)", // 8
|
"Eesti Vabariik [Republic of Estonia]", // 8
|
||||||
"Principat d'Andorra", // 9
|
"Principat d'Andorra", // 9
|
||||||
"Repubblica di San Marino", // 10
|
"Repubblica di San Marino", // 10
|
||||||
"Rzeczpospolita Polska", // 11
|
"Rzeczpospolita Polska", // 11
|
||||||
@@ -118,17 +118,17 @@ static const char* const ECCtext[] {
|
|||||||
"The former Yugoslav Republic of Macedonia", // 16
|
"The former Yugoslav Republic of Macedonia", // 16
|
||||||
"Repubblica Italiana", // 17
|
"Repubblica Italiana", // 17
|
||||||
"Hashemite Kingdom of Jordan", // 18
|
"Hashemite Kingdom of Jordan", // 18
|
||||||
"Slovenská republika", // 19
|
"Slovenská republika [Republic of Slovakia]", // 19
|
||||||
"Koninkrijk België / Royaume de Belgique", // 20
|
"Koninkrijk België / Royaume de Belgique [Kingdom of Belgium]", // 20
|
||||||
"Suomen tasavalta / (Republic of Finland)", // 21
|
"Suomen tasavalta [Republic of Finland]", // 21
|
||||||
"Syrian Arab Republic", // 22
|
"Syrian Arab Republic", // 22
|
||||||
"Republic of Serbia", // 23
|
"Републике Србије [Republic of Serbia]", // 23
|
||||||
"Україна / (Ukraine)", // 24
|
"Україна [Ukraine]", // 24
|
||||||
"Российская Федерация / (Russian Federation)", // 25
|
"Российская Федерация [Russian Federation]", // 25
|
||||||
"Groussherzogtum Lëtzebuerg / (Grand Duchy of Luxembourg)", // 26
|
"Groussherzogtum Lëtzebuerg [Grand Duchy of Luxembourg]", // 26
|
||||||
"Republic of Tunisia", // 27
|
"Republic of Tunisia", // 27
|
||||||
"State of Palestine", // 28
|
"State of Palestine", // 28
|
||||||
"Република България / (Republic of Bulgaria)", // 29
|
"Република България [Republic of Bulgaria]", // 29
|
||||||
"Republic of Portugal (Madeira)", // 30
|
"Republic of Portugal (Madeira)", // 30
|
||||||
"Koninkrijk der Nederlanden", // 31
|
"Koninkrijk der Nederlanden", // 31
|
||||||
"Republic of Portugal", // 32
|
"Republic of Portugal", // 32
|
||||||
@@ -146,13 +146,13 @@ static const char* const ECCtext[] {
|
|||||||
"Principality of Monaco", // 44
|
"Principality of Monaco", // 44
|
||||||
"Republic of Malta", // 45
|
"Republic of Malta", // 45
|
||||||
"United Kingdom of Great Britain and Northern Ireland", // 46
|
"United Kingdom of Great Britain and Northern Ireland", // 46
|
||||||
"Lietuvos Respublika / (Republic of Lithuania)", // 47
|
"Lietuvos Respublika [Republic of Lithuania]", // 47
|
||||||
"Republika Hrvatska / (Republic of Croatia)", // 48
|
"Republika Hrvatska [Republic of Croatia]", // 48
|
||||||
"Libya", // 49
|
"Libya", // 49
|
||||||
"Kingdom of Spain (Canary Islands)", // 50
|
"Kingdom of Spain (Canary Islands)", // 50
|
||||||
"România", // 51
|
"România", // 51
|
||||||
"Reino de España / (Kingdom of Spain)", // 52
|
"Reino de España [Kingdom of Spain]", // 52
|
||||||
"Konungariket Sverige / (Kingdom of Sweden)", // 53
|
"Konungariket Sverige [Kingdom of Sweden]", // 53
|
||||||
"Arab Republic of Egypt", // 54
|
"Arab Republic of Egypt", // 54
|
||||||
"République de France", // 55
|
"République de France", // 55
|
||||||
"Kongeriket Norge", // 56
|
"Kongeriket Norge", // 56
|
||||||
@@ -239,7 +239,7 @@ static const char* const ECCtext[] {
|
|||||||
"República Federativa do Brasil", // 137
|
"República Federativa do Brasil", // 137
|
||||||
"Canada", // 138
|
"Canada", // 138
|
||||||
"United Kingdom of Great Britain and Northern Ireland (Cayman Islands)", // 139
|
"United Kingdom of Great Britain and Northern Ireland (Cayman Islands)", // 139
|
||||||
"Republic of Chile", // 140
|
"República de Chile", // 140
|
||||||
"Republic of Colombia", // 141
|
"Republic of Colombia", // 141
|
||||||
"Republic of Costa Rica", // 142
|
"Republic of Costa Rica", // 142
|
||||||
"Republic of Cuba", // 143
|
"Republic of Cuba", // 143
|
||||||
@@ -250,20 +250,20 @@ static const char* const ECCtext[] {
|
|||||||
"United Kingdom of Great Britain and Northern Ireland (Falkland Islands)", // 148
|
"United Kingdom of Great Britain and Northern Ireland (Falkland Islands)", // 148
|
||||||
"Kingdom of Denmark (Greenland, NOT USA)", // 149
|
"Kingdom of Denmark (Greenland, NOT USA)", // 149
|
||||||
"Grenada", // 150
|
"Grenada", // 150
|
||||||
"Republic of France (Guadeloupe)", // 151
|
"République française (Guadeloupe)", // 151
|
||||||
"Republic of Guatemala", // 152
|
"Republic of Guatemala", // 152
|
||||||
"Republic of Guyana", // 153
|
"Republic of Guyana", // 153
|
||||||
"Republic of Haiti", // 154
|
"Republic of Haiti", // 154
|
||||||
"Republic of Honduras", // 155
|
"Republic of Honduras", // 155
|
||||||
"Jamaica", // 156
|
"Jamaica", // 156
|
||||||
"Republic of France (Martinique)", // 157
|
"République française (Martinique)", // 157
|
||||||
"Estados Unidos Mexicanos", // 158
|
"Estados Unidos Mexicanos", // 158
|
||||||
"United Kingdom of Great Britain and Northern Ireland (Montserrat)", // 159
|
"United Kingdom of Great Britain and Northern Ireland (Montserrat)", // 159
|
||||||
"Netherlands Antilles (does not exist)", // 160
|
"Netherlands Antilles", // 160
|
||||||
"Republic of Nicaragua", // 161
|
"Republic of Nicaragua", // 161
|
||||||
"Republic of Panama", // 162
|
"Republic of Panama", // 162
|
||||||
"Republic of Paraguay", // 163
|
"República del Paraguay", // 163
|
||||||
"Republic of Peru", // 164
|
"República del Perú", // 164
|
||||||
"United States of America (Puerto Rico)", // 165
|
"United States of America (Puerto Rico)", // 165
|
||||||
"Saint Kitts and Nevis", // 166
|
"Saint Kitts and Nevis", // 166
|
||||||
"Saint Lucia", // 167
|
"Saint Lucia", // 167
|
||||||
@@ -289,18 +289,18 @@ static const char* const ECCtext[] {
|
|||||||
"Kingdom of Bhutan", // 187
|
"Kingdom of Bhutan", // 187
|
||||||
"Negara Brunei Darussalam", // 188
|
"Negara Brunei Darussalam", // 188
|
||||||
"Kingdom of Cambodia", // 189
|
"Kingdom of Cambodia", // 189
|
||||||
"People's Republic of China", // 190
|
"中华人民共和国 [PRC]", // 190
|
||||||
"Republic of Fiji", // 191
|
"Republic of Fiji", // 191
|
||||||
"People's Republic of China (Hong Kong)", // 192
|
"中华人民共和国(香港 [PRC, HK]", // 192
|
||||||
"Republic of India", // 193
|
"Republic of India", // 193
|
||||||
"Republic of Indonesia", // 194
|
"Republic of Indonesia", // 194
|
||||||
"Islamic Republic of Iran", // 195
|
"Islamic Republic of Iran", // 195
|
||||||
"Japan", // 196
|
"Japan", // 196
|
||||||
"Republic of Kiribati", // 197
|
"Republic of Kiribati", // 197
|
||||||
"Democratic People's Republic of Korea (North Korea)", // 198
|
"Democratic People's Republic of Korea [North Korea]", // 198
|
||||||
"Republic of Korea (South Korea)", // 199
|
"Republic of Korea [South Korea]", // 199
|
||||||
"Lao People's Democratic Republic", // 200
|
"Lao People's Democratic Republic", // 200
|
||||||
"People's Republic of China (Macao)", // 201
|
"中华人民共和国(澳门) [PRC, M]", // 201
|
||||||
"Malaysia", // 202
|
"Malaysia", // 202
|
||||||
"Republic of Maldives", // 203
|
"Republic of Maldives", // 203
|
||||||
"United States of America (Marshall Islands)", // 204
|
"United States of America (Marshall Islands)", // 204
|
||||||
@@ -316,7 +316,7 @@ static const char* const ECCtext[] {
|
|||||||
"Republic of Singapore", // 214
|
"Republic of Singapore", // 214
|
||||||
"Solomon Islands", // 215
|
"Solomon Islands", // 215
|
||||||
"Democratic Socialist Republic of Sri Lanka", // 216
|
"Democratic Socialist Republic of Sri Lanka", // 216
|
||||||
"Republic of China (Taiwan)", // 217
|
"Republic of China [Taiwan]", // 217
|
||||||
"Kingdom of Thailand", // 218
|
"Kingdom of Thailand", // 218
|
||||||
"Kingdom of Tonga", // 219
|
"Kingdom of Tonga", // 219
|
||||||
"Republic of Vanuatu", // 220
|
"Republic of Vanuatu", // 220
|
||||||
@@ -324,7 +324,7 @@ static const char* const ECCtext[] {
|
|||||||
"Commonwealth of the Bahamas", // 222
|
"Commonwealth of the Bahamas", // 222
|
||||||
"United Kingdom of Great Britain and Northern Ireland (Bermuda) / Federative Republic of Brazil", // 223
|
"United Kingdom of Great Britain and Northern Ireland (Bermuda) / Federative Republic of Brazil", // 223
|
||||||
"Federative Republic of Brazil / Republic of Ecuador", // 224
|
"Federative Republic of Brazil / Republic of Ecuador", // 224
|
||||||
"Netherlands Antilles (does not exist) / Federative Republic of Brazil", // 225
|
"Netherlands Antilles / Federative Republic of Brazil", // 225
|
||||||
"United States of America", // 226
|
"United States of America", // 226
|
||||||
"People's Republic of Bangladesh", // 227
|
"People's Republic of Bangladesh", // 227
|
||||||
"Rzeczpospolita Zachodniej Polski" // 228 - doesn't exist, YET, we don't want a fucking pimp for president here
|
"Rzeczpospolita Zachodniej Polski" // 228 - doesn't exist, YET, we don't want a fucking pimp for president here
|
||||||
@@ -462,7 +462,7 @@ typedef struct _rds_ {
|
|||||||
bool rdsDerror;
|
bool rdsDerror;
|
||||||
Detector<bool, 1> hasArtificialhead{false};
|
Detector<bool, 1> hasArtificialhead{false};
|
||||||
Detector<bool, 1> hasCompressed{false};
|
Detector<bool, 1> hasCompressed{false};
|
||||||
bool hasDynamicPTY;
|
Detector<bool, 1> hasDynamicPTY{false};
|
||||||
Detector<bool, 1> hasStereo{false};
|
Detector<bool, 1> hasStereo{false};
|
||||||
bool hasRDS;
|
bool hasRDS;
|
||||||
bool hasECC;
|
bool hasECC;
|
||||||
@@ -534,9 +534,9 @@ class TEF6686 {
|
|||||||
void SetFreq(uint16_t frequency);
|
void SetFreq(uint16_t frequency);
|
||||||
void SetFreqAM(uint16_t frequency);
|
void SetFreqAM(uint16_t frequency);
|
||||||
void getProcessing(uint16_t &highcut, uint16_t &stereo, uint16_t &sthiblend, uint8_t &stband_1, uint8_t &stband_2, uint8_t &stband_3, uint8_t &stband_4);
|
void getProcessing(uint16_t &highcut, uint16_t &stereo, uint16_t &sthiblend, uint8_t &stband_1, uint8_t &stband_2, uint8_t &stband_3, uint8_t &stband_4);
|
||||||
void getStatus(int16_t *level, uint16_t *USN, uint16_t *WAM, int16_t *offset, uint16_t *bandwidth, uint16_t *modulation, int8_t *snr);
|
void getStatus(int16_t *level, uint16_t *USN, uint16_t *WAM, int16_t *offset, uint16_t *bandwidth, uint16_t *audiolevel);
|
||||||
void getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel, int16_t *offset, uint16_t *bandwidth, uint16_t *modulation, int8_t *snr);
|
void getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel, int16_t *offset, uint16_t *bandwidth, uint16_t *audiolevel);
|
||||||
void getIdentification(uint16_t *device, uint16_t *hw_version, uint16_t *sw_version);
|
uint16_t getIdentification(uint16_t *hw_version, uint16_t *sw_version);
|
||||||
void setSoftmuteFM(uint8_t mode);
|
void setSoftmuteFM(uint8_t mode);
|
||||||
void setSoftmuteAM(uint8_t mode);
|
void setSoftmuteAM(uint8_t mode);
|
||||||
void setMono(bool mono);
|
void setMono(bool mono);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ typedef enum {
|
|||||||
Cmd_Set_NoiseBlanker_Audio = 24,
|
Cmd_Set_NoiseBlanker_Audio = 24,
|
||||||
Cmd_Set_Deemphasis = 31,
|
Cmd_Set_Deemphasis = 31,
|
||||||
Cmd_Set_StereoImprovement = 32,
|
Cmd_Set_StereoImprovement = 32,
|
||||||
|
Cmd_Set_LevelStep = 38,
|
||||||
Cmd_Set_LevelOffset = 39,
|
Cmd_Set_LevelOffset = 39,
|
||||||
Cmd_Set_Softmute_Max = 45,
|
Cmd_Set_Softmute_Max = 45,
|
||||||
Cmd_Set_Highcut_Level = 52,
|
Cmd_Set_Highcut_Level = 52,
|
||||||
@@ -31,6 +32,7 @@ typedef enum {
|
|||||||
Cmd_Set_Highcut_Mph = 54,
|
Cmd_Set_Highcut_Mph = 54,
|
||||||
Cmd_Set_Highcut_Max = 55,
|
Cmd_Set_Highcut_Max = 55,
|
||||||
Cmd_Set_LowCut_Max = 57,
|
Cmd_Set_LowCut_Max = 57,
|
||||||
|
Cmd_Set_LowCut_Min = 58,
|
||||||
Cmd_Set_Stereo_Time = 60,
|
Cmd_Set_Stereo_Time = 60,
|
||||||
Cmd_Set_Stereo_Level = 62,
|
Cmd_Set_Stereo_Level = 62,
|
||||||
Cmd_Set_Stereo_Noise = 63,
|
Cmd_Set_Stereo_Noise = 63,
|
||||||
@@ -78,7 +80,7 @@ void devTEF_Set_Cmd(TEF_MODULE module, uint8_t cmd, uint16_t len, ...);
|
|||||||
bool devTEF_Get_Cmd(TEF_MODULE module, uint8_t cmd, uint8_t *receive, uint16_t len);
|
bool devTEF_Get_Cmd(TEF_MODULE module, uint8_t cmd, uint8_t *receive, uint16_t len);
|
||||||
void devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq);
|
void devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq);
|
||||||
|
|
||||||
void devTEF_Radio_Get_Quality_Status(uint16_t *status, int16_t *level, uint16_t *usn, uint16_t *wam, int16_t *offset, uint16_t *bandwidth, uint16_t *mod, int8_t *snr);
|
void devTEF_Radio_Get_Quality_Data(uint16_t *status, int16_t *level, uint16_t *usn, uint16_t *wam, int16_t *offset, uint16_t *bandwidth, uint16_t *audiolevel);
|
||||||
uint8_t devTEF_APPL_Get_Operation_Status();
|
uint8_t devTEF_APPL_Get_Operation_Status();
|
||||||
void devTEF_Radio_Get_RDS_Status(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error);
|
void devTEF_Radio_Get_RDS_Status(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error);
|
||||||
void devTEF_Radio_Get_RDS_Data(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error);
|
void devTEF_Radio_Get_RDS_Data(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error);
|
||||||
+4
-19
@@ -3,36 +3,21 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "nonvolatile.h"
|
#include "nonvolatile.h"
|
||||||
#include <Hash.h>
|
#include <Hash.h>
|
||||||
|
#include "core.h"
|
||||||
|
#include "gui.h"
|
||||||
|
|
||||||
void Communication();
|
void Communication();
|
||||||
void XDRGTKRoutine();
|
void XDRGTKRoutine();
|
||||||
void passwordcrypt();
|
void passwordcrypt();
|
||||||
void tryWiFi();
|
void tryWiFi();
|
||||||
|
void wifiPoll();
|
||||||
|
void total_pc_control();
|
||||||
|
|
||||||
extern void DataPrint(String string);
|
|
||||||
extern void ShowFreq(int mode);
|
|
||||||
extern void SelectBand();
|
|
||||||
extern void doBW();
|
|
||||||
extern void BuildDisplay();
|
extern void BuildDisplay();
|
||||||
extern void BuildAdvancedRDS();
|
extern void BuildAdvancedRDS();
|
||||||
extern void ModeButtonPress();
|
|
||||||
extern void Seek(bool mode);
|
|
||||||
extern void doStereoToggle();
|
|
||||||
extern void MuteScreen(bool setting);
|
|
||||||
extern void updateiMS();
|
|
||||||
extern void updateEQ();
|
|
||||||
extern void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize);
|
|
||||||
extern void showAutoSquelch(bool mode);
|
|
||||||
extern void ShowStepSize();
|
|
||||||
extern void startFMDXScan();
|
|
||||||
extern void cancelDXScan();
|
|
||||||
extern void printLogbookCSV();
|
extern void printLogbookCSV();
|
||||||
extern void NTPupdate();
|
extern void NTPupdate();
|
||||||
extern void handleRoot();
|
extern void handleRoot();
|
||||||
extern void handleDownloadCSV();
|
extern void handleDownloadCSV();
|
||||||
extern void handleLogo();
|
extern void handleLogo();
|
||||||
extern void Infoboxprint(const char* input);
|
extern void Infoboxprint(const char* input);
|
||||||
extern void TuneUp();
|
|
||||||
extern void TuneDown();
|
|
||||||
extern void ShowTuneMode();
|
|
||||||
extern const char* textUI(uint16_t number);
|
|
||||||
|
|||||||
+69
-143
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define VERSION "v2.20.5e"
|
#define VERSION "v2.20.7b"
|
||||||
|
|
||||||
#define ROTARY_PIN_A 34
|
#define ROTARY_PIN_A 34
|
||||||
#define ROTARY_PIN_B 36
|
#define ROTARY_PIN_B 36
|
||||||
@@ -22,24 +22,55 @@
|
|||||||
|
|
||||||
#define RX8010SJ_ADDRESS 0x32 // Address of the RTC chip in the DP666 receivers
|
#define RX8010SJ_ADDRESS 0x32 // Address of the RTC chip in the DP666 receivers
|
||||||
|
|
||||||
#define REVERSE false
|
|
||||||
|
|
||||||
#define ALEFT -1
|
#define ALEFT -1
|
||||||
#define ACENTER 0
|
#define ACENTER 0
|
||||||
#define ARIGHT 1
|
#define ARIGHT 1
|
||||||
|
|
||||||
#define MAX(x, y) (x) < (y) ? (y) : (x)
|
|
||||||
#define MIN(X, Y) {\
|
|
||||||
typeof (X) x_ = (X);\
|
|
||||||
typeof (Y) y_ = (Y);\
|
|
||||||
(x_ < y_) ? x_ : y_; }
|
|
||||||
|
|
||||||
#define TIMER_OFFSET_TIMER 250
|
#define TIMER_OFFSET_TIMER 250
|
||||||
#define TIMER_BW_TIMER 300
|
#define TIMER_BW_TIMER 300
|
||||||
#define TIMER_SNR_TIMER 30
|
#define TIMER_SNR_TIMER 30
|
||||||
#define TIMER_BAT_TIMER 750
|
#define TIMER_BAT_TIMER 750
|
||||||
|
|
||||||
#define BAT_LEVEL_STAGE 8
|
// Signal quality thresholds for scanning
|
||||||
|
#define SCAN_SIGNAL_THRESHOLD_USN_MULTIPLIER 30
|
||||||
|
#define SCAN_SIGNAL_THRESHOLD_WAM 230
|
||||||
|
#define SCAN_SIGNAL_THRESHOLD_OSTATUS 80
|
||||||
|
#define SCAN_SIGNAL_THRESHOLD_OSTATUS_WIDE 100
|
||||||
|
|
||||||
|
// Timing constants (milliseconds)
|
||||||
|
#define DELAY_TUNE_MS 50
|
||||||
|
#define DELAY_UI_UPDATE_MS 200
|
||||||
|
#define DELAY_BUTTON_DEBOUNCE_MS 50
|
||||||
|
#define DELAY_BUTTON_DEBOUNCE_EXTRA_MS 75
|
||||||
|
#define DELAY_KEYPAD_TIMEOUT_MS 2000
|
||||||
|
#define DELAY_RDS_READ_MS 60
|
||||||
|
#define DELAY_TOUCH_REPEAT_MS 500
|
||||||
|
#define TOT_MULTIPLIER_MS 60000
|
||||||
|
#define NTP_UPDATE_INTERVAL_MS 1800000
|
||||||
|
#define UDP_LOG_INTERVAL_MS 500
|
||||||
|
#define SCAN_HOLD_DEFAULT_MS 500
|
||||||
|
|
||||||
|
// UI layout coordinates
|
||||||
|
#define STEREO_ICON_X 32
|
||||||
|
#define STEREO_ICON_Y 5
|
||||||
|
#define WIFI_ICON_X 282
|
||||||
|
#define WIFI_ICON_Y 3
|
||||||
|
#define WIFI_ICON_WIDTH 30
|
||||||
|
#define WIFI_ICON_HEIGHT 25
|
||||||
|
#define SPEAKER_ICON_X 249
|
||||||
|
#define SPEAKER_ICON_Y 4
|
||||||
|
#define SPEAKER_ICON_WIDTH 28
|
||||||
|
#define SPEAKER_ICON_HEIGHT 24
|
||||||
|
|
||||||
|
// Touch thresholds
|
||||||
|
#define TOUCH_RAW_Z_THRESHOLD 235
|
||||||
|
|
||||||
|
// Battery detection
|
||||||
|
#define BATTERY_DETECT_THRESHOLD 200 // About 0.161V
|
||||||
|
|
||||||
|
// Squelch values
|
||||||
|
#define SQUELCH_MAX_VALUE 920
|
||||||
|
|
||||||
#define BATTERY_LOW_VALUE 3.2
|
#define BATTERY_LOW_VALUE 3.2
|
||||||
#define BATTERY_FULL_VALUE 4.12
|
#define BATTERY_FULL_VALUE 4.12
|
||||||
|
|
||||||
@@ -224,134 +255,6 @@
|
|||||||
#define ITEM9 190
|
#define ITEM9 190
|
||||||
#define ITEM10 210
|
#define ITEM10 210
|
||||||
|
|
||||||
// EEPROM index defines
|
|
||||||
#define EE_PRESETS_CNT 99 // When set > 99 change the complete EEPROM adressing!
|
|
||||||
#define EE_CHECKBYTE_VALUE 20 // 0 ~ 255,add new entry, change for new value
|
|
||||||
#define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
|
|
||||||
#define EE_TOTAL_CNT 2287 // Total occupied eeprom bytes
|
|
||||||
|
|
||||||
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte
|
|
||||||
#define EE_PRESET_BW_START 99 // 99 * 1 byte
|
|
||||||
#define EE_PRESET_MS_START 198 // 99 * 1 byte
|
|
||||||
#define EE_PRESETS_FREQUENCY_START 297 // 99 * 4 bytes
|
|
||||||
#define EE_PRESETS_RDSPI_START 693 // 99 * 5 bytes
|
|
||||||
#define EE_PRESETS_RDSPS_START 1188 // 99 * 9 bytes
|
|
||||||
|
|
||||||
#define EE_UINT16_FREQUENCY_FM 2079
|
|
||||||
#define EE_BYTE_VOLSET 2083
|
|
||||||
#define EE_BYTE_STEREO 2084
|
|
||||||
#define EE_BYTE_BANDFM 2085
|
|
||||||
#define EE_BYTE_BANDAM 2086
|
|
||||||
#define EE_UINT16_CONVERTERSET 2087
|
|
||||||
#define EE_UINT16_FMLOWEDGESET 2091
|
|
||||||
#define EE_UINT16_FMHIGHEDGESET 2095
|
|
||||||
#define EE_BYTE_CONTRASTSET 2099
|
|
||||||
#define EE_BYTE_STEREOLEVEL 2100
|
|
||||||
#define EE_BYTE_HIGHCUTLEVEL 2101
|
|
||||||
#define EE_BYTE_HIGHCUTOFFSET 2102
|
|
||||||
#define EE_BYTE_LEVELOFFSET 2103
|
|
||||||
#define EE_BYTE_RTBUFFER 2104
|
|
||||||
#define EE_BYTE_SORTAF 2105
|
|
||||||
#define EE_BYTE_STATIONLISTID 2106
|
|
||||||
#define EE_BYTE_EDGEBEEP 2107
|
|
||||||
#define EE_BYTE_SOFTMUTEAM 2108
|
|
||||||
#define EE_BYTE_SOFTMUTEFM 2109
|
|
||||||
#define EE_UINT16_FREQUENCY_AM 2110
|
|
||||||
#define EE_BYTE_LANGUAGE 2114
|
|
||||||
#define EE_BYTE_SHOWRDSERRORS 2115
|
|
||||||
#define EE_BYTE_TEF 2116
|
|
||||||
#define EE_BYTE_DISPLAYFLIP 2117
|
|
||||||
#define EE_BYTE_ROTARYMODE 2118
|
|
||||||
#define EE_BYTE_STEPSIZE 2119
|
|
||||||
#define EE_BYTE_TUNEMODE 2120
|
|
||||||
// empty byte
|
|
||||||
#define EE_BYTE_CHECKBYTE 2122
|
|
||||||
#define EE_BYTE_IMSSET 2123
|
|
||||||
#define EE_BYTE_EQSET 2124
|
|
||||||
#define EE_BYTE_BAND 2125
|
|
||||||
#define EE_BYTE_LOWLEVELSET 2126
|
|
||||||
#define EE_BYTE_BWSET_FM 2127
|
|
||||||
#define EE_BYTE_BWSET_AM 2128
|
|
||||||
#define EE_BYTE_BANDAUTOSW 2129
|
|
||||||
#define EE_BYTE_MEMORYPOS 2130
|
|
||||||
#define EE_BYTE_REGION 2131
|
|
||||||
#define EE_BYTE_RDS_UNDERSCORE 2132
|
|
||||||
#define EE_BYTE_USBMODE 2133
|
|
||||||
#define EE_BYTE_WIFI 2134
|
|
||||||
#define EE_BYTE_SUBNETCLIENT 2135
|
|
||||||
#define EE_BYTE_SHOWSWMIBAND 2136
|
|
||||||
#define EE_BYTE_RDS_FILTER 2137
|
|
||||||
#define EE_BYTE_RDS_PIERRORS 2138
|
|
||||||
#define EE_BYTE_USESQUELCH 2139
|
|
||||||
#define EE_BYTE_SHOWMODULATION 2140
|
|
||||||
#define EE_BYTE_AM_NB 2141
|
|
||||||
#define EE_BYTE_FM_NB 2142
|
|
||||||
#define EE_BYTE_AUDIOMODE 2143
|
|
||||||
#define EE_BYTE_TOUCH_ROTATING 2144
|
|
||||||
#define EE_BYTE_HARDWARE_MODEL 2145
|
|
||||||
#define EE_BYTE_POWEROPTIONS 2146
|
|
||||||
#define EE_BYTE_CURRENTTHEME 2147
|
|
||||||
#define EE_BYTE_FMDEFAULTSTEPSIZE 2148
|
|
||||||
#define EE_BYTE_SCREENSAVERSET 2149
|
|
||||||
#define EE_BYTE_UNIT 2150
|
|
||||||
#define EE_BYTE_AF 2151
|
|
||||||
#define EE_BYTE_BATTERY_OPTIONS 2152
|
|
||||||
#define EE_BYTE_AM_CO_DECT 2153
|
|
||||||
#define EE_BYTE_AM_CO_DECT_COUNT 2154
|
|
||||||
#define EE_BYTE_AM_RF_GAIN 2155
|
|
||||||
#define EE_BYTE_FM_DEEMPHASIS 2156
|
|
||||||
#define EE_UINT16_FREQUENCY_LW 2157
|
|
||||||
#define EE_UINT16_FREQUENCY_MW 2161
|
|
||||||
#define EE_UINT16_FREQUENCY_SW 2165
|
|
||||||
#define EE_UINT16_LOWEDGEOIRTSET 2169
|
|
||||||
#define EE_UINT16_HIGHEDGEOIRTSET 2173
|
|
||||||
#define EE_INT16_AMLEVELOFFSET 2177
|
|
||||||
#define EE_UINT16_FREQUENCY_OIRT 2181
|
|
||||||
#define EE_STRING_XDRGTK_KEY 2185 // 11 byte
|
|
||||||
#define EE_BYTE_FASTPS 2196
|
|
||||||
#define EE_BYTE_TOT 2197
|
|
||||||
#define EE_BYTE_MWREGION 2198
|
|
||||||
#define EE_BYTE_SPISPEED 2199
|
|
||||||
#define EE_BYTE_AMSCANSENS 2200
|
|
||||||
#define EE_BYTE_FMSCANSENS 2201
|
|
||||||
#define EE_BYTE_FREQFONT 2202
|
|
||||||
// Empty space, this was not used
|
|
||||||
#define EE_BYTE_XDRGTKMUTE 2204
|
|
||||||
#define EE_BYTE_FMAGC 2205
|
|
||||||
#define EE_BYTE_AMAGC 2206
|
|
||||||
#define EE_BYTE_FMSI 2207
|
|
||||||
#define EE_BYTE_SCANSTART 2208
|
|
||||||
#define EE_BYTE_SCANSTOP 2209
|
|
||||||
#define EE_BYTE_SCANHOLD 2210
|
|
||||||
#define EE_BYTE_SCANMEM 2211
|
|
||||||
#define EE_BYTE_SCANCANCEL 2212
|
|
||||||
#define EE_BYTE_SCANMUTE 2213
|
|
||||||
#define EE_BYTE_AUTOSQUELCH 2214
|
|
||||||
#define EE_BYTE_LONGBANDPRESS 2215
|
|
||||||
#define EE_BYTE_SHOWCLOCK 2216
|
|
||||||
#define EE_BYTE_SHOWLONGPS 2217
|
|
||||||
#define EE_UINT16_MEMSTARTFREQ 2218
|
|
||||||
#define EE_UINT16_MEMSTOPFREQ 2222
|
|
||||||
#define EE_BYTE_MEMSTARTPOS 2226
|
|
||||||
#define EE_BYTE_MEMSTOPPOS 2227
|
|
||||||
#define EE_BYTE_MEMPIONLY 2228
|
|
||||||
#define EE_BYTE_MEMDOUBLEPI 2229
|
|
||||||
// blank space
|
|
||||||
#define EE_BYTE_WAITONLYONSIGNAL 2253
|
|
||||||
#define EE_UINT16_CALTOUCH1 2254
|
|
||||||
#define EE_UINT16_CALTOUCH2 2258
|
|
||||||
#define EE_UINT16_CALTOUCH3 2262
|
|
||||||
#define EE_UINT16_CALTOUCH4 2266
|
|
||||||
#define EE_UINT16_CALTOUCH5 2270
|
|
||||||
#define EE_BYTE_INVERTDISPLAY 2274
|
|
||||||
#define EE_BYTE_NTPOFFSET 2275
|
|
||||||
#define EE_BYTE_AUTOLOG 2276
|
|
||||||
#define EE_BYTE_AUTODST 2277
|
|
||||||
#define EE_BYTE_CLOCKAMPM 2278
|
|
||||||
#define EE_UINT16_LOGCOUNTER 2279
|
|
||||||
#define EE_UINT16_PICTLOCK 2283
|
|
||||||
// End of EEPROM index defines
|
|
||||||
|
|
||||||
// Memory channel database
|
// Memory channel database
|
||||||
typedef struct {
|
typedef struct {
|
||||||
byte bw;
|
byte bw;
|
||||||
@@ -414,11 +317,6 @@ enum RADIO_FM_DEEMPHASIS {
|
|||||||
DEEMPHASIS_COUNT
|
DEEMPHASIS_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SPI_SPEED_ENUM {
|
|
||||||
SPI_SPEED_DEFAULT = 0, SPI_SPEED_10M, SPI_SPEED_20M, SPI_SPEED_30M, SPI_SPEED_40M, SPI_SPEED_50M, SPI_SPEED_60M, SPI_SPEED_70M,
|
|
||||||
SPI_SPEED_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
enum RADIO_MEM_POS_STATUS {
|
enum RADIO_MEM_POS_STATUS {
|
||||||
MEM_DARK, MEM_NORMAL, MEM_EXIST
|
MEM_DARK, MEM_NORMAL, MEM_EXIST
|
||||||
};
|
};
|
||||||
@@ -673,6 +571,34 @@ static const uint8_t WiFi4[] PROGMEM = {
|
|||||||
0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const uint8_t WiFiX[] PROGMEM = {
|
||||||
|
0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x18, 0x00, 0x00, 0x60,
|
||||||
|
0x0C, 0x00, 0x00, 0xC0,
|
||||||
|
0x06, 0x00, 0x01, 0x80,
|
||||||
|
0x03, 0x00, 0x03, 0x00,
|
||||||
|
0x01, 0x80, 0x06, 0x00,
|
||||||
|
0x00, 0xC0, 0x0C, 0x00,
|
||||||
|
0x00, 0x60, 0x18, 0x00,
|
||||||
|
0x00, 0x30, 0x30, 0x00,
|
||||||
|
0x00, 0x18, 0x60, 0x00,
|
||||||
|
0x00, 0x0C, 0xC0, 0x00,
|
||||||
|
0x00, 0x07, 0x80, 0x00,
|
||||||
|
0x00, 0x07, 0x80, 0x00,
|
||||||
|
0x00, 0x07, 0x80, 0x00,
|
||||||
|
0x00, 0x0C, 0xC0, 0x00,
|
||||||
|
0x00, 0x18, 0x60, 0x00,
|
||||||
|
0x00, 0x30, 0x30, 0x00,
|
||||||
|
0x00, 0x60, 0x18, 0x00,
|
||||||
|
0x00, 0xC0, 0x0C, 0x00,
|
||||||
|
0x01, 0x80, 0x06, 0x00,
|
||||||
|
0x03, 0x00, 0x03, 0x00,
|
||||||
|
0x06, 0x00, 0x01, 0x80,
|
||||||
|
0x0C, 0x00, 0x00, 0xC0,
|
||||||
|
0x18, 0x00, 0x00, 0x60,
|
||||||
|
0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
static const uint16_t radiologo[] PROGMEM = {
|
static const uint16_t radiologo[] PROGMEM = {
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
const char* textUI(uint16_t number);
|
||||||
|
uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, uint8_t stopmem, bool rdsonly, uint8_t doublepi);
|
||||||
|
void setAutoSpeedSPI();
|
||||||
|
void DoMemoryPosTune();
|
||||||
|
void startFMDXScan();
|
||||||
|
void endMenu();
|
||||||
|
void TuneUp();
|
||||||
|
void ShowFreq(int mode);
|
||||||
|
void ShowMemoryPos();
|
||||||
|
void TuneDown();
|
||||||
|
void ShowTuneMode();
|
||||||
|
void SelectBand();
|
||||||
|
void doBW();
|
||||||
|
void ModeButtonPress();
|
||||||
|
void Seek(bool mode);
|
||||||
|
void MuteScreen(bool setting);
|
||||||
|
void cancelDXScan();
|
||||||
|
void doStereoToggle();
|
||||||
|
void DataPrint(String string);
|
||||||
+11
-9
@@ -5,15 +5,15 @@
|
|||||||
#include "TEF6686.h"
|
#include "TEF6686.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "change_detector.h"
|
#include "change_detector.h"
|
||||||
|
#include "nonvolatile.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <WiFiConnect.h>
|
|
||||||
#include <WiFiConnectParam.h>
|
|
||||||
#include "scrolling_text.h"
|
#include "scrolling_text.h"
|
||||||
#include "rtc.hpp"
|
#include "rtc.hpp"
|
||||||
|
#include "WiFiConnect.h"
|
||||||
|
|
||||||
extern bool RDSstatus;
|
extern bool RDSstatus;
|
||||||
extern bool RDSstatusold;
|
extern bool RDSstatusold;
|
||||||
@@ -26,7 +26,7 @@ extern bool autosquelch, batterydetect, beepresetstart;
|
|||||||
extern bool beepresetstop, BWreset, bwtouchtune;
|
extern bool beepresetstop, BWreset, bwtouchtune;
|
||||||
extern bool BWtune, change, clockampm;
|
extern bool BWtune, change, clockampm;
|
||||||
extern bool direction, dropout;
|
extern bool direction, dropout;
|
||||||
extern bool dynamicPTYold, edgebeep, externaltune;
|
extern bool edgebeep, externaltune;
|
||||||
extern bool findMemoryAF;
|
extern bool findMemoryAF;
|
||||||
extern bool firstTouchHandled;
|
extern bool firstTouchHandled;
|
||||||
extern bool flashing;
|
extern bool flashing;
|
||||||
@@ -138,7 +138,7 @@ extern byte scanhold;
|
|||||||
extern byte scanmodeold;
|
extern byte scanmodeold;
|
||||||
extern byte screensaverOptions[5];
|
extern byte screensaverOptions[5];
|
||||||
extern byte screensaverset;
|
extern byte screensaverset;
|
||||||
extern byte showmodulation;
|
extern byte showaudio;
|
||||||
extern byte showrdserrors;
|
extern byte showrdserrors;
|
||||||
extern byte showSWMIBand;
|
extern byte showSWMIBand;
|
||||||
extern byte submenu;
|
extern byte submenu;
|
||||||
@@ -229,9 +229,7 @@ extern int8_t MPold;
|
|||||||
extern int8_t USold;
|
extern int8_t USold;
|
||||||
extern int8_t LevelOffset;
|
extern int8_t LevelOffset;
|
||||||
extern int8_t LowLevelSet;
|
extern int8_t LowLevelSet;
|
||||||
extern int8_t NTPoffset;
|
extern int8_t Timezone;
|
||||||
extern int8_t CN;
|
|
||||||
extern int8_t CNold;
|
|
||||||
extern int8_t VolSet;
|
extern int8_t VolSet;
|
||||||
extern float batteryVold;
|
extern float batteryVold;
|
||||||
extern IPAddress remoteip;
|
extern IPAddress remoteip;
|
||||||
@@ -261,6 +259,7 @@ extern String XDRGTK_key;
|
|||||||
extern Detector<String, 1> XDRGTKRDS;
|
extern Detector<String, 1> XDRGTKRDS;
|
||||||
extern uint16_t BW;
|
extern uint16_t BW;
|
||||||
extern uint16_t MStatus;
|
extern uint16_t MStatus;
|
||||||
|
extern bool modLevelForceRedraw;
|
||||||
extern uint16_t SWMIBandPos;
|
extern uint16_t SWMIBandPos;
|
||||||
extern uint16_t SWMIBandPosold;
|
extern uint16_t SWMIBandPosold;
|
||||||
extern uint16_t TouchCalData[5];
|
extern uint16_t TouchCalData[5];
|
||||||
@@ -317,8 +316,8 @@ extern unsigned long flashingtimer;
|
|||||||
extern unsigned long keypadtimer;
|
extern unsigned long keypadtimer;
|
||||||
extern unsigned long lastTouchTime;
|
extern unsigned long lastTouchTime;
|
||||||
extern unsigned long lowsignaltimer;
|
extern unsigned long lowsignaltimer;
|
||||||
extern unsigned long ModulationpreviousMillis;
|
extern unsigned long AudiopreviousMillis;
|
||||||
extern unsigned long ModulationpeakPreviousMillis;
|
extern unsigned long AudiopeakPreviousMillis;
|
||||||
extern unsigned long NTPtimer;
|
extern unsigned long NTPtimer;
|
||||||
extern unsigned long peakholdmillis;
|
extern unsigned long peakholdmillis;
|
||||||
extern unsigned long processed_rdsblocksold[33];
|
extern unsigned long processed_rdsblocksold[33];
|
||||||
@@ -336,6 +335,9 @@ extern bool rds_settings_changed;
|
|||||||
extern const size_t language_totalnumber;
|
extern const size_t language_totalnumber;
|
||||||
extern const size_t language_entrynumber;
|
extern const size_t language_entrynumber;
|
||||||
|
|
||||||
|
extern volatile bool i2c_pc_control;
|
||||||
|
extern volatile bool i2c_pc_control_init;
|
||||||
|
|
||||||
extern mem presets[EE_PRESETS_CNT];
|
extern mem presets[EE_PRESETS_CNT];
|
||||||
extern TEF6686 radio;
|
extern TEF6686 radio;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize);
|
||||||
|
void tftPrint16(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, bool force_font = true, bool font = false);
|
||||||
|
void tftReplace(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, uint8_t fontsize);
|
||||||
|
void tftReplace16(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, bool force_font = true, bool font = false);
|
||||||
|
void UpdateFonts();
|
||||||
+9
-19
@@ -3,12 +3,13 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "menugraphics.h"
|
#include "menugraphics.h"
|
||||||
|
#include "core.h"
|
||||||
|
|
||||||
static const char* const unitString[] = {"dBμV", "dBf", "dBm"};
|
static const char* const unitString[] = {"dBμV", "dBf", "dBm"};
|
||||||
static const char* const FreqFont[] = {"Classic", "Roubenstil", "Motoya", "Aura2", "Comic", "Modern"};
|
static const char* const FreqFont[] = {"Classic", "Roubenstil", "Motoya", "Aura2", "Comic", "Modern"};
|
||||||
static const char* const Theme[] = {"Essence", "Cyan", "Crimson", "Monochrome", "Volcano", "Dendro", "Sakura", "Whiteout", "Tangerine", "Ocean", "Indigo", "Queer", "GoldBrite", "Bubblegum"};
|
static const char* const Theme[] = {"Essence", "Cyan", "Crimson", "Monochrome", "Volcano", "Dendro", "Sakura", "Whiteout", "Tangerine", "Ocean", "Indigo", "Queer", "GoldBrite", "Bubblegum"};
|
||||||
static const char* BWButtonLabelsFM[] = {"56 kHz", "64 kHz", "72 kHz", "84 kHz", "97 kHz", "114 kHz", "133 kHz", "151 kHz", "168 kHz", "184 kHz", "200 kHz", "217 kHz", "236 kHz", "254 kHz", "287 kHz", "311 kHz", "Auto", "iMS", "EQ"};
|
extern const char* BWButtonLabelsFM[];
|
||||||
static const char* BWButtonLabelsAM[] = {"3 kHz", "4 kHz", "6 kHz", "8 kHz"};
|
extern const char* BWButtonLabelsAM[];
|
||||||
|
|
||||||
void BuildAFScreen();
|
void BuildAFScreen();
|
||||||
void BuildRDSStatScreen();
|
void BuildRDSStatScreen();
|
||||||
@@ -24,28 +25,17 @@ void drawButton(const char* text, byte button_number, bool active, bool selected
|
|||||||
String shortLine(String text);
|
String shortLine(String text);
|
||||||
void showMenuOpenTouchButtons();
|
void showMenuOpenTouchButtons();
|
||||||
void showBWSelector();
|
void showBWSelector();
|
||||||
|
void ShowRDSLogo(bool RDSstatus);
|
||||||
|
void showAutoSquelch(bool mode);
|
||||||
|
void updateEQ();
|
||||||
|
void updateiMS();
|
||||||
|
void updateBW();
|
||||||
|
void ShowStepSize();
|
||||||
|
|
||||||
extern void ShowFreq(int mode);
|
|
||||||
extern void ShowBandSelectionFM(bool notglanceview, bool normaldisplay);
|
extern void ShowBandSelectionFM(bool notglanceview, bool normaldisplay);
|
||||||
extern void ShowBandSelectionAM(bool notglanceview, bool normaldisplay);
|
extern void ShowBandSelectionAM(bool notglanceview, bool normaldisplay);
|
||||||
extern void ScreensaverTimerSet(byte value);
|
extern void ScreensaverTimerSet(byte value);
|
||||||
extern void ShowMemoryPos();
|
|
||||||
extern void ShowTuneMode();
|
|
||||||
extern void updateBW();
|
|
||||||
extern void ShowStepSize();
|
|
||||||
extern void updateiMS();
|
|
||||||
extern void updateEQ();
|
|
||||||
extern void doTheme();
|
extern void doTheme();
|
||||||
extern void tryWiFi();
|
extern void tryWiFi();
|
||||||
extern void TuneUp();
|
|
||||||
extern void endMenu();
|
|
||||||
extern void startFMDXScan();
|
|
||||||
extern void DoMemoryPosTune();
|
|
||||||
extern void UpdateFonts();
|
|
||||||
extern void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize);
|
|
||||||
extern void setAutoSpeedSPI();
|
|
||||||
extern void showAutoSquelch(bool mode);
|
|
||||||
extern uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, uint8_t stopmem, bool rdsonly, uint8_t doublepi);
|
|
||||||
extern void ClearMemoryRange(uint8_t start, uint8_t stop);
|
extern void ClearMemoryRange(uint8_t start, uint8_t stop);
|
||||||
extern bool handleCreateNewLogbook();
|
extern bool handleCreateNewLogbook();
|
||||||
extern const char* textUI(uint16_t number);
|
|
||||||
+2570
-2152
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -6,6 +6,7 @@ using fs::FS;
|
|||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "rtc.hpp"
|
#include "rtc.hpp"
|
||||||
|
#include "core.h"
|
||||||
|
|
||||||
void handleRoot();
|
void handleRoot();
|
||||||
void handleDownloadCSV();
|
void handleDownloadCSV();
|
||||||
@@ -17,5 +18,3 @@ void handleLogo();
|
|||||||
void printLogbookCSV();
|
void printLogbookCSV();
|
||||||
void sendUDPlog();
|
void sendUDPlog();
|
||||||
IPAddress makeBroadcastAddress(IPAddress ip);
|
IPAddress makeBroadcastAddress(IPAddress ip);
|
||||||
|
|
||||||
extern const char* textUI(uint16_t number);
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "system_console.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
extern Console console;
|
||||||
|
extern RTC_DATA_ATTR bool gpio_chip;
|
||||||
|
extern RTC_DATA_ATTR bool tef_found;
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
void panic(Args... args) {
|
||||||
|
radio.power(true);
|
||||||
|
tft.fillScreen(TFT_RED);
|
||||||
|
console.reset();
|
||||||
|
|
||||||
|
(console.print(args), ...);
|
||||||
|
while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Round30K(unsigned int freq);
|
||||||
|
void Round50K(unsigned int freq);
|
||||||
|
void Round100K(unsigned int freq);
|
||||||
|
void Round200K(unsigned int freq);
|
||||||
|
void WakeToSleep(bool yes);
|
||||||
|
void BANDBUTTONPress();
|
||||||
|
void BWButtonPress();
|
||||||
|
void doBandToggle();
|
||||||
|
int GetNum();
|
||||||
|
void NumpadProcess(int num);
|
||||||
|
|
||||||
|
bool isSignalQualityGood(int usn, int wam, int ostatus, int threshold_multiplier = SCAN_SIGNAL_THRESHOLD_USN_MULTIPLIER, int ostatus_threshold = SCAN_SIGNAL_THRESHOLD_OSTATUS);
|
||||||
|
void deepSleep();
|
||||||
|
inline bool IsStationEmpty() {
|
||||||
|
return presets[memorypos].band == BAND_FM && presets[memorypos].frequency == EE_PRESETS_FREQUENCY;
|
||||||
|
}
|
||||||
+131
-2
@@ -1,7 +1,136 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include "globals.h"
|
|
||||||
#include "logbook.h"
|
// EEPROM index defines
|
||||||
|
#define EE_PRESETS_CNT 99 // When set > 99 change the complete EEPROM adressing!
|
||||||
|
#define EE_CHECKBYTE_VALUE 20 // 0 ~ 255,add new entry, change for new value
|
||||||
|
#define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
|
||||||
|
#define EE_TOTAL_CNT 2296 // Total occupied eeprom bytes, we can take 20K
|
||||||
|
|
||||||
|
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte
|
||||||
|
#define EE_PRESET_BW_START 99 // 99 * 1 byte
|
||||||
|
#define EE_PRESET_MS_START 198 // 99 * 1 byte
|
||||||
|
#define EE_PRESETS_FREQUENCY_START 297 // 99 * 4 bytes
|
||||||
|
#define EE_PRESETS_RDSPI_START 693 // 99 * 5 bytes
|
||||||
|
#define EE_PRESETS_RDSPS_START 1188 // 99 * 9 bytes
|
||||||
|
|
||||||
|
#define EE_UINT16_FREQUENCY_FM 2079
|
||||||
|
#define EE_BYTE_VOLSET 2083
|
||||||
|
#define EE_BYTE_STEREO 2084
|
||||||
|
#define EE_BYTE_BANDFM 2085
|
||||||
|
#define EE_BYTE_BANDAM 2086
|
||||||
|
#define EE_UINT16_CONVERTERSET 2087
|
||||||
|
#define EE_UINT16_FMLOWEDGESET 2091
|
||||||
|
#define EE_UINT16_FMHIGHEDGESET 2095
|
||||||
|
#define EE_BYTE_CONTRASTSET 2099
|
||||||
|
#define EE_BYTE_STEREOLEVEL 2100
|
||||||
|
#define EE_BYTE_HIGHCUTLEVEL 2101
|
||||||
|
#define EE_BYTE_HIGHCUTOFFSET 2102
|
||||||
|
#define EE_BYTE_LEVELOFFSET 2103
|
||||||
|
#define EE_BYTE_RTBUFFER 2104
|
||||||
|
#define EE_BYTE_SORTAF 2105
|
||||||
|
#define EE_BYTE_STATIONLISTID 2106
|
||||||
|
#define EE_BYTE_EDGEBEEP 2107
|
||||||
|
#define EE_BYTE_SOFTMUTEAM 2108
|
||||||
|
#define EE_BYTE_SOFTMUTEFM 2109
|
||||||
|
#define EE_UINT16_FREQUENCY_AM 2110
|
||||||
|
#define EE_BYTE_LANGUAGE 2114
|
||||||
|
#define EE_BYTE_SHOWRDSERRORS 2115
|
||||||
|
#define EE_BYTE_TEF 2116
|
||||||
|
#define EE_BYTE_DISPLAYFLIP 2117
|
||||||
|
#define EE_BYTE_ROTARYMODE 2118
|
||||||
|
#define EE_BYTE_STEPSIZE 2119
|
||||||
|
#define EE_BYTE_TUNEMODE 2120
|
||||||
|
// empty byte
|
||||||
|
#define EE_BYTE_CHECKBYTE 2122
|
||||||
|
#define EE_BYTE_IMSSET 2123
|
||||||
|
#define EE_BYTE_EQSET 2124
|
||||||
|
#define EE_BYTE_BAND 2125
|
||||||
|
#define EE_BYTE_LOWLEVELSET 2126
|
||||||
|
#define EE_BYTE_BWSET_FM 2127
|
||||||
|
#define EE_BYTE_BWSET_AM 2128
|
||||||
|
#define EE_BYTE_BANDAUTOSW 2129
|
||||||
|
#define EE_BYTE_MEMORYPOS 2130
|
||||||
|
#define EE_BYTE_REGION 2131
|
||||||
|
#define EE_BYTE_RDS_UNDERSCORE 2132
|
||||||
|
#define EE_BYTE_USBMODE 2133
|
||||||
|
#define EE_BYTE_WIFI 2134
|
||||||
|
#define EE_BYTE_SUBNETCLIENT 2135
|
||||||
|
#define EE_BYTE_SHOWSWMIBAND 2136
|
||||||
|
#define EE_BYTE_RDS_FILTER 2137
|
||||||
|
#define EE_BYTE_RDS_PIERRORS 2138
|
||||||
|
#define EE_BYTE_USESQUELCH 2139
|
||||||
|
#define EE_BYTE_SHOWAUDIO 2140
|
||||||
|
#define EE_BYTE_AM_NB 2141
|
||||||
|
#define EE_BYTE_FM_NB 2142
|
||||||
|
#define EE_BYTE_AUDIOMODE 2143
|
||||||
|
#define EE_BYTE_TOUCH_ROTATING 2144
|
||||||
|
#define EE_BYTE_HARDWARE_MODEL 2145
|
||||||
|
#define EE_BYTE_POWEROPTIONS 2146
|
||||||
|
#define EE_BYTE_CURRENTTHEME 2147
|
||||||
|
#define EE_BYTE_FMDEFAULTSTEPSIZE 2148
|
||||||
|
#define EE_BYTE_SCREENSAVERSET 2149
|
||||||
|
#define EE_BYTE_UNIT 2150
|
||||||
|
#define EE_BYTE_AF 2151
|
||||||
|
#define EE_BYTE_BATTERY_OPTIONS 2152
|
||||||
|
#define EE_BYTE_AM_CO_DECT 2153
|
||||||
|
#define EE_BYTE_AM_CO_DECT_COUNT 2154
|
||||||
|
#define EE_BYTE_AM_RF_GAIN 2155
|
||||||
|
#define EE_BYTE_FM_DEEMPHASIS 2156
|
||||||
|
#define EE_UINT16_FREQUENCY_LW 2157
|
||||||
|
#define EE_UINT16_FREQUENCY_MW 2161
|
||||||
|
#define EE_UINT16_FREQUENCY_SW 2165
|
||||||
|
#define EE_UINT16_LOWEDGEOIRTSET 2169
|
||||||
|
#define EE_UINT16_HIGHEDGEOIRTSET 2173
|
||||||
|
#define EE_INT16_AMLEVELOFFSET 2177
|
||||||
|
#define EE_UINT16_FREQUENCY_OIRT 2181
|
||||||
|
#define EE_STRING_XDRGTK_KEY 2185 // 11 byte
|
||||||
|
#define EE_BYTE_FASTPS 2196
|
||||||
|
#define EE_BYTE_TOT 2197
|
||||||
|
#define EE_BYTE_MWREGION 2198
|
||||||
|
#define EE_BYTE_SPISPEED 2199
|
||||||
|
#define EE_BYTE_AMSCANSENS 2200
|
||||||
|
#define EE_BYTE_FMSCANSENS 2201
|
||||||
|
#define EE_BYTE_FREQFONT 2202
|
||||||
|
// Empty space, this was not used
|
||||||
|
#define EE_BYTE_XDRGTKMUTE 2204
|
||||||
|
#define EE_BYTE_FMAGC 2205
|
||||||
|
#define EE_BYTE_AMAGC 2206
|
||||||
|
#define EE_BYTE_FMSI 2207
|
||||||
|
#define EE_BYTE_SCANSTART 2208
|
||||||
|
#define EE_BYTE_SCANSTOP 2209
|
||||||
|
#define EE_BYTE_SCANHOLD 2210
|
||||||
|
#define EE_BYTE_SCANMEM 2211
|
||||||
|
#define EE_BYTE_SCANCANCEL 2212
|
||||||
|
#define EE_BYTE_SCANMUTE 2213
|
||||||
|
#define EE_BYTE_AUTOSQUELCH 2214
|
||||||
|
#define EE_BYTE_LONGBANDPRESS 2215
|
||||||
|
#define EE_BYTE_SHOWCLOCK 2216
|
||||||
|
#define EE_BYTE_SHOWLONGPS 2217
|
||||||
|
#define EE_UINT16_MEMSTARTFREQ 2218
|
||||||
|
#define EE_UINT16_MEMSTOPFREQ 2222
|
||||||
|
#define EE_BYTE_MEMSTARTPOS 2226
|
||||||
|
#define EE_BYTE_MEMSTOPPOS 2227
|
||||||
|
#define EE_BYTE_MEMPIONLY 2228
|
||||||
|
#define EE_BYTE_MEMDOUBLEPI 2229
|
||||||
|
// blank space
|
||||||
|
#define EE_BYTE_WAITONLYONSIGNAL 2253
|
||||||
|
#define EE_UINT16_CALTOUCH1 2254
|
||||||
|
#define EE_UINT16_CALTOUCH2 2258
|
||||||
|
#define EE_UINT16_CALTOUCH3 2262
|
||||||
|
#define EE_UINT16_CALTOUCH4 2266
|
||||||
|
#define EE_UINT16_CALTOUCH5 2270
|
||||||
|
#define EE_BYTE_INVERTDISPLAY 2274
|
||||||
|
#define EE_BYTE_TIMEZONE 2275
|
||||||
|
#define EE_BYTE_AUTOLOG 2276
|
||||||
|
#define EE_BYTE_AUTODST 2277
|
||||||
|
#define EE_BYTE_CLOCKAMPM 2278
|
||||||
|
#define EE_UINT16_LOGCOUNTER 2279
|
||||||
|
#define EE_UINT16_PICTLOCK 2283
|
||||||
|
#define EE_BYTE_CONTROLMODE 2285
|
||||||
|
// End of EEPROM index defines
|
||||||
|
#define EE_START_CONTROLMODE_DATA 2286
|
||||||
|
#define EE_LEN_CONTROLMODE_DATA 8
|
||||||
|
|
||||||
void StoreFrequency();
|
void StoreFrequency();
|
||||||
void ClearMemoryRange(uint8_t start, uint8_t stop);
|
void ClearMemoryRange(uint8_t start, uint8_t stop);
|
||||||
|
|||||||
+3
-8
@@ -4,11 +4,13 @@
|
|||||||
#include <TFT_eSPI.h>
|
#include <TFT_eSPI.h>
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include "TEF6686.h"
|
#include "TEF6686.h"
|
||||||
#include <WiFi.h>
|
|
||||||
#include <ESP32Time.h>
|
#include <ESP32Time.h>
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "NTPupdate.h"
|
#include "NTPupdate.h"
|
||||||
#include "rtc.hpp"
|
#include "rtc.hpp"
|
||||||
|
#include "core.h"
|
||||||
|
#include "gui.h"
|
||||||
|
#include "logbook.h"
|
||||||
|
|
||||||
void ShowAdvancedRDS();
|
void ShowAdvancedRDS();
|
||||||
void readRds();
|
void readRds();
|
||||||
@@ -21,10 +23,3 @@ void ShowAFEON();
|
|||||||
void showCT();
|
void showCT();
|
||||||
void ShowErrors();
|
void ShowErrors();
|
||||||
void ShowRDSStatistics();
|
void ShowRDSStatistics();
|
||||||
|
|
||||||
extern void ShowRDSLogo(bool RDSstatus);
|
|
||||||
extern void DataPrint(String string);
|
|
||||||
extern void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize);
|
|
||||||
extern void tftReplace(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, uint8_t fontsize);
|
|
||||||
extern bool isDST(time_t t);
|
|
||||||
extern const char* textUI(uint16_t number);
|
|
||||||
|
|||||||
+1
-1
@@ -12,4 +12,4 @@ extern ESP32Time rtc;
|
|||||||
extern bool rx_rtc_avail;
|
extern bool rx_rtc_avail;
|
||||||
|
|
||||||
bool init_rtc();
|
bool init_rtc();
|
||||||
void set_time(time_t time);
|
void set_time(time_t time, int8_t offset);
|
||||||
+13
-11
@@ -13,7 +13,7 @@ private:
|
|||||||
unsigned long lastTick;
|
unsigned long lastTick;
|
||||||
unsigned long holdTick;
|
unsigned long holdTick;
|
||||||
bool isScrolling;
|
bool isScrolling;
|
||||||
std::function<void(TFT_eSprite*, bool)> postDrawCallback;
|
std::function<void(TFT_eSprite*)> postDrawCallback;
|
||||||
int usedH;
|
int usedH;
|
||||||
bool hold;
|
bool hold;
|
||||||
int xOffset;
|
int xOffset;
|
||||||
@@ -26,17 +26,17 @@ public:
|
|||||||
ScrollingTextDisplay(TFT_eSprite* spr, int y, int maxW, int x = 35, int inuseH = -1 ) :
|
ScrollingTextDisplay(TFT_eSprite* spr, int y, int maxW, int x = 35, int inuseH = -1 ) :
|
||||||
sprite(spr), yPos(y), maxWidth(maxW), xPos(0), textWidth(0), lastTick(0), holdTick(0), isScrolling(false), postDrawCallback(nullptr), usedH(inuseH), hold(false), xOffset(x) {}
|
sprite(spr), yPos(y), maxWidth(maxW), xPos(0), textWidth(0), lastTick(0), holdTick(0), isScrolling(false), postDrawCallback(nullptr), usedH(inuseH), hold(false), xOffset(x) {}
|
||||||
|
|
||||||
void setPostDrawCallback(std::function<void(TFT_eSprite*, bool)> callback) {
|
void setPostDrawCallback(std::function<void(TFT_eSprite*)> callback) {
|
||||||
postDrawCallback = callback;
|
postDrawCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor) {
|
void update(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor, uint8_t font = 255) {
|
||||||
textWidth = sprite->textWidth(text);
|
textWidth = sprite->textWidth(text);
|
||||||
|
|
||||||
if(textWidth < maxWidth) {
|
if(textWidth < maxWidth) {
|
||||||
xPos = 0;
|
xPos = 0;
|
||||||
isScrolling = false;
|
isScrolling = false;
|
||||||
drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor);
|
drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor, font);
|
||||||
} else {
|
} else {
|
||||||
if(!isScrolling) holdTick = millis();
|
if(!isScrolling) holdTick = millis();
|
||||||
isScrolling = true;
|
isScrolling = true;
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
holdTick = millis();
|
holdTick = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor);
|
drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor, font);
|
||||||
lastTick = millis();
|
lastTick = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawText(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor) {
|
void drawText(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor, uint8_t font) {
|
||||||
|
if(font > FONT_COUNT) font = sprite->textfont;
|
||||||
|
|
||||||
if(usedH > 0) {
|
if(usedH > 0) {
|
||||||
sprite->fillSprite(TFT_TRANSPARENT);
|
sprite->fillSprite(TFT_TRANSPARENT);
|
||||||
sprite->fillRect(0, 0, maxWidth, usedH, backgroundColor);
|
sprite->fillRect(0, 0, maxWidth, usedH, backgroundColor);
|
||||||
@@ -85,8 +87,8 @@ private:
|
|||||||
if(status) sprite->setTextColor(activeColor, activeSmooth, false);
|
if(status) sprite->setTextColor(activeColor, activeSmooth, false);
|
||||||
else sprite->setTextColor(dropoutColor, dropoutSmooth, false);
|
else sprite->setTextColor(dropoutColor, dropoutSmooth, false);
|
||||||
|
|
||||||
sprite->drawString(text, xPos, 0);
|
sprite->drawString(text, xPos, 0, font);
|
||||||
if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0);
|
if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0, font);
|
||||||
|
|
||||||
sprite->resetViewport();
|
sprite->resetViewport();
|
||||||
} else {
|
} else {
|
||||||
@@ -95,11 +97,11 @@ private:
|
|||||||
if(status) sprite->setTextColor(activeColor, activeSmooth, false);
|
if(status) sprite->setTextColor(activeColor, activeSmooth, false);
|
||||||
else sprite->setTextColor(dropoutColor, dropoutSmooth, false);
|
else sprite->setTextColor(dropoutColor, dropoutSmooth, false);
|
||||||
|
|
||||||
sprite->drawString(text, xPos, 0);
|
sprite->drawString(text, xPos, 0, font);
|
||||||
if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0);
|
if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(postDrawCallback) postDrawCallback(sprite, false);
|
if(postDrawCallback) postDrawCallback(sprite);
|
||||||
if(yPos != 0) sprite->pushSprite(xOffset, yPos, TFT_TRANSPARENT);
|
if(yPos != 0) sprite->pushSprite(xOffset, yPos, TFT_TRANSPARENT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <TFT_eSPI.h>
|
#include <TFT_eSPI.h>
|
||||||
|
|
||||||
|
#define CONSOLE_FONT 2
|
||||||
|
|
||||||
class Console {
|
class Console {
|
||||||
public:
|
public:
|
||||||
explicit Console(TFT_eSPI* display) : tft(display), y(0) {}
|
explicit Console(TFT_eSPI* display) : tft(display), y(0) {}
|
||||||
@@ -9,9 +11,9 @@ public:
|
|||||||
tft->setTextColor(TFT_WHITE, background);
|
tft->setTextColor(TFT_WHITE, background);
|
||||||
tft->setTextDatum(TL_DATUM);
|
tft->setTextDatum(TL_DATUM);
|
||||||
auto data = "[" + String(millis() / 1000.0f) + "] " + text;
|
auto data = "[" + String(millis() / 1000.0f) + "] " + text;
|
||||||
tft->fillRect(0, y, tft->textWidth(data), tft->fontHeight(0), background);
|
tft->fillRect(0, y, tft->textWidth(data, CONSOLE_FONT), tft->fontHeight(CONSOLE_FONT), background);
|
||||||
tft->drawString(data, 0, y, 0);
|
tft->drawString(data, 0, y, CONSOLE_FONT);
|
||||||
y += tft->fontHeight(0);
|
y += tft->fontHeight(CONSOLE_FONT);
|
||||||
}
|
}
|
||||||
void reset() {
|
void reset() {
|
||||||
y = 0;
|
y = 0;
|
||||||
|
|||||||
+3
-7
@@ -1,28 +1,24 @@
|
|||||||
|
// This is ancient
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "core.h"
|
||||||
|
|
||||||
void doTouchEvent(uint16_t x, uint16_t y);
|
void doTouchEvent(uint16_t x, uint16_t y);
|
||||||
|
|
||||||
extern void BuildDisplay();
|
extern void BuildDisplay();
|
||||||
extern void BuildBWSelector();
|
extern void BuildBWSelector();
|
||||||
extern void SelectBand();
|
|
||||||
extern void BuildAdvancedRDS();
|
extern void BuildAdvancedRDS();
|
||||||
extern void doBandToggle();
|
extern void doBandToggle();
|
||||||
extern void doTuneMode();
|
extern void doTuneMode();
|
||||||
extern void doStereoToggle();
|
|
||||||
extern void cancelDXScan();
|
|
||||||
extern void doBW();
|
|
||||||
extern void drawButton(const char* text, byte button_number, bool active, bool selected);
|
extern void drawButton(const char* text, byte button_number, bool active, bool selected);
|
||||||
extern void KeyDown();
|
extern void KeyDown();
|
||||||
extern void KeyUp();
|
extern void KeyUp();
|
||||||
extern void ButtonPress();
|
extern void ButtonPress();
|
||||||
extern void DoMenu();
|
extern void DoMenu();
|
||||||
extern void ModeButtonPress();
|
|
||||||
extern void toggleiMSEQ();
|
extern void toggleiMSEQ();
|
||||||
extern void showBWSelector();
|
extern void showBWSelector();
|
||||||
extern void updateiMS();
|
extern void updateiMS();
|
||||||
extern void updateEQ();
|
extern void updateEQ();
|
||||||
extern void DataPrint(String string);
|
|
||||||
extern void BuildAFScreen();
|
extern void BuildAFScreen();
|
||||||
extern void ShowFreq(int mode);
|
|
||||||
|
|||||||
@@ -27,19 +27,8 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
|
|
||||||
#ifdef RTC_DATA_ATTR
|
|
||||||
RTC_DATA_ATTR static bool overflow;
|
RTC_DATA_ATTR static bool overflow;
|
||||||
#else
|
|
||||||
static bool overflow;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
|
||||||
@brief set the internal RTC time
|
|
||||||
@param epoch
|
|
||||||
epoch time in seconds
|
|
||||||
@param ms
|
|
||||||
microseconds (optional)
|
|
||||||
*/
|
|
||||||
void ESP32Time::setTime(unsigned long epoch, int ms) const {
|
void ESP32Time::setTime(unsigned long epoch, int ms) const {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
if (epoch > 2082758399){
|
if (epoch > 2082758399){
|
||||||
@@ -53,27 +42,19 @@ void ESP32Time::setTime(unsigned long epoch, int ms) const {
|
|||||||
settimeofday(&tv, NULL);
|
settimeofday(&tv, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
@brief get the internal RTC time as a tm struct
|
|
||||||
*/
|
|
||||||
tm ESP32Time::getTimeStruct() const {
|
tm ESP32Time::getTimeStruct() const {
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
time_t tt = mktime (&timeinfo);
|
|
||||||
|
|
||||||
|
time_t tt = mktime(&timeinfo);
|
||||||
if (overflow) tt += 63071999;
|
if (overflow) tt += 63071999;
|
||||||
struct tm* tn = localtime(&tt);
|
struct tm* tn = localtime(&tt);
|
||||||
if (overflow){
|
if (overflow) tn->tm_year += 64;
|
||||||
tn->tm_year += 64;
|
|
||||||
}
|
|
||||||
return *tn;
|
return *tn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
@brief get the current epoch seconds as unsigned long
|
|
||||||
*/
|
|
||||||
unsigned long ESP32Time::getEpoch() const {
|
unsigned long ESP32Time::getEpoch() const {
|
||||||
struct tm timeinfo = getTimeStruct();
|
struct tm timeinfo = getTimeStruct();
|
||||||
return mktime(&timeinfo);
|
return mktime(&timeinfo);
|
||||||
|
|||||||
@@ -25,10 +25,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
class ESP32Time {
|
class ESP32Time {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setTime(unsigned long epoch, int ms = 0) const;
|
void setTime(unsigned long epoch, int ms = 0) const;
|
||||||
tm getTimeStruct() const;
|
tm getTimeStruct() const;
|
||||||
|
|
||||||
unsigned long getEpoch() const;
|
unsigned long getEpoch() const;
|
||||||
};
|
};
|
||||||
@@ -38,33 +38,11 @@ extern "C" {
|
|||||||
* @param hash uint8_t[20]
|
* @param hash uint8_t[20]
|
||||||
*/
|
*/
|
||||||
void sha1(uint8_t * data, uint32_t size, uint8_t hash[20]) {
|
void sha1(uint8_t * data, uint32_t size, uint8_t hash[20]) {
|
||||||
|
|
||||||
SHA1_CTX ctx;
|
SHA1_CTX ctx;
|
||||||
|
|
||||||
#ifdef DEBUG_SHA1
|
|
||||||
os_printf("DATA:");
|
|
||||||
for(uint16_t i = 0; i < size; i++) {
|
|
||||||
os_printf("%02X", data[i]);
|
|
||||||
}
|
|
||||||
os_printf("\n");
|
|
||||||
os_printf("DATA:");
|
|
||||||
for(uint16_t i = 0; i < size; i++) {
|
|
||||||
os_printf("%c", data[i]);
|
|
||||||
}
|
|
||||||
os_printf("\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SHA1Init(&ctx);
|
SHA1Init(&ctx);
|
||||||
SHA1Update(&ctx, data, size);
|
SHA1Update(&ctx, data, size);
|
||||||
SHA1Final(hash, &ctx);
|
SHA1Final(hash, &ctx);
|
||||||
|
|
||||||
#ifdef DEBUG_SHA1
|
|
||||||
os_printf("SHA1:");
|
|
||||||
for(uint16_t i = 0; i < 20; i++) {
|
|
||||||
os_printf("%02X", hash[i]);
|
|
||||||
}
|
|
||||||
os_printf("\n\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sha1(char * data, uint32_t size, uint8_t hash[20]) {
|
void sha1(char * data, uint32_t size, uint8_t hash[20]) {
|
||||||
|
|||||||
+1
-6
@@ -22,10 +22,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HASH_H_
|
#pragma once
|
||||||
#define HASH_H_
|
|
||||||
|
|
||||||
//#define DEBUG_SHA1
|
|
||||||
|
|
||||||
void sha1(uint8_t * data, uint32_t size, uint8_t hash[20]);
|
void sha1(uint8_t * data, uint32_t size, uint8_t hash[20]);
|
||||||
void sha1(char * data, uint32_t size, uint8_t hash[20]);
|
void sha1(char * data, uint32_t size, uint8_t hash[20]);
|
||||||
@@ -38,5 +35,3 @@ String sha1(char* data, uint32_t size);
|
|||||||
String sha1(const uint8_t* data, uint32_t size);
|
String sha1(const uint8_t* data, uint32_t size);
|
||||||
String sha1(const char* data, uint32_t size);
|
String sha1(const char* data, uint32_t size);
|
||||||
String sha1(String data);
|
String sha1(String data);
|
||||||
|
|
||||||
#endif /* HASH_H_ */
|
|
||||||
|
|||||||
@@ -23,34 +23,18 @@
|
|||||||
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* #define LITTLE_ENDIAN * This should be #define'd already, if true. */
|
|
||||||
/* #define SHA1HANDSOFF * Copies data before messing with it. */
|
|
||||||
|
|
||||||
#define SHA1HANDSOFF
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#ifndef ESP32
|
|
||||||
#include <c_types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
|
|
||||||
//#include <endian.h>
|
|
||||||
|
|
||||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||||
|
|
||||||
/* blk0() and blk() perform the initial expand. */
|
/* blk0() and blk() perform the initial expand. */
|
||||||
/* I got the idea of expanding during the round function from SSLeay */
|
/* I got the idea of expanding during the round function from SSLeay */
|
||||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
|
||||||
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|
||||||
|(rol(block->l[i],8)&0x00FF00FF))
|
|(rol(block->l[i],8)&0x00FF00FF))
|
||||||
#elif BYTE_ORDER == BIG_ENDIAN
|
|
||||||
#define blk0(i) block->l[i]
|
|
||||||
#else
|
|
||||||
#error "Endianness not defined!"
|
|
||||||
#endif
|
|
||||||
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
||||||
^block->l[(i+2)&15]^block->l[i&15],1))
|
^block->l[(i+2)&15]^block->l[i&15],1))
|
||||||
|
|
||||||
@@ -61,26 +45,14 @@
|
|||||||
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
|
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
|
||||||
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
|
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
|
||||||
|
|
||||||
|
STATIC void ICACHE_FLASH_ATTR SHA1Transform(uint32_t state[5], uint8_t buffer[64]) {
|
||||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
|
||||||
STATIC void ICACHE_FLASH_ATTR SHA1Transform(uint32_t state[5], uint8_t buffer[64])
|
|
||||||
{
|
|
||||||
uint32_t a, b, c, d, e;
|
uint32_t a, b, c, d, e;
|
||||||
typedef union {
|
typedef union {
|
||||||
unsigned char c[64];
|
unsigned char c[64];
|
||||||
uint32_t l[16];
|
uint32_t l[16];
|
||||||
} CHAR64LONG16;
|
} CHAR64LONG16;
|
||||||
#ifdef SHA1HANDSOFF
|
|
||||||
CHAR64LONG16 block[1]; /* use array to appear as a pointer */
|
CHAR64LONG16 block[1]; /* use array to appear as a pointer */
|
||||||
memcpy(block, buffer, 64);
|
memcpy(block, buffer, 64);
|
||||||
#else
|
|
||||||
/* The following had better never be used because it causes the
|
|
||||||
* pointer-to-const buffer to be cast into a pointer to non-const.
|
|
||||||
* And the result is written through. I threw a "const" in, hoping
|
|
||||||
* this will cause a diagnostic.
|
|
||||||
*/
|
|
||||||
CHAR64LONG16* block = (const CHAR64LONG16*)buffer;
|
|
||||||
#endif
|
|
||||||
/* Copy context->state[] to working vars */
|
/* Copy context->state[] to working vars */
|
||||||
a = state[0];
|
a = state[0];
|
||||||
b = state[1];
|
b = state[1];
|
||||||
@@ -116,18 +88,11 @@ CHAR64LONG16* block = (const CHAR64LONG16*)buffer;
|
|||||||
state[4] += e;
|
state[4] += e;
|
||||||
/* Wipe variables */
|
/* Wipe variables */
|
||||||
a = b = c = d = e = 0;
|
a = b = c = d = e = 0;
|
||||||
#ifdef SHA1HANDSOFF
|
|
||||||
memset(block, '\0', sizeof(block));
|
memset(block, '\0', sizeof(block));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC void ICACHE_FLASH_ATTR SHA1Init(SHA1_CTX* context) {
|
||||||
/* SHA1Init - Initialize new context */
|
context->state[0] = 0x67452301; // six seven
|
||||||
|
|
||||||
STATIC void ICACHE_FLASH_ATTR SHA1Init(SHA1_CTX* context)
|
|
||||||
{
|
|
||||||
/* SHA1 initialization constants */
|
|
||||||
context->state[0] = 0x67452301;
|
|
||||||
context->state[1] = 0xEFCDAB89;
|
context->state[1] = 0xEFCDAB89;
|
||||||
context->state[2] = 0x98BADCFE;
|
context->state[2] = 0x98BADCFE;
|
||||||
context->state[3] = 0x10325476;
|
context->state[3] = 0x10325476;
|
||||||
@@ -135,13 +100,8 @@ STATIC void ICACHE_FLASH_ATTR SHA1Init(SHA1_CTX* context)
|
|||||||
context->count[0] = context->count[1] = 0;
|
context->count[0] = context->count[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC void ICACHE_FLASH_ATTR SHA1Update(SHA1_CTX* context, uint8_t* data, uint32_t len) {
|
||||||
/* Run your data through this. */
|
uint32_t i, j;
|
||||||
|
|
||||||
STATIC void ICACHE_FLASH_ATTR SHA1Update(SHA1_CTX* context, uint8_t* data, uint32_t len)
|
|
||||||
{
|
|
||||||
uint32_t i;
|
|
||||||
uint32_t j;
|
|
||||||
|
|
||||||
j = context->count[0];
|
j = context->count[0];
|
||||||
if ((context->count[0] += len << 3) < j)
|
if ((context->count[0] += len << 3) < j)
|
||||||
@@ -151,9 +111,7 @@ STATIC void ICACHE_FLASH_ATTR SHA1Update(SHA1_CTX* context, uint8_t* data, uint3
|
|||||||
if ((j + len) > 63) {
|
if ((j + len) > 63) {
|
||||||
memcpy(&context->buffer[j], data, (i = 64-j));
|
memcpy(&context->buffer[j], data, (i = 64-j));
|
||||||
SHA1Transform(context->state, context->buffer);
|
SHA1Transform(context->state, context->buffer);
|
||||||
for ( ; i + 63 < len; i += 64) {
|
for ( ; i + 63 < len; i += 64) SHA1Transform(context->state, &data[i]);
|
||||||
SHA1Transform(context->state, &data[i]);
|
|
||||||
}
|
|
||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
else i = 0;
|
else i = 0;
|
||||||
@@ -163,34 +121,15 @@ STATIC void ICACHE_FLASH_ATTR SHA1Update(SHA1_CTX* context, uint8_t* data, uint3
|
|||||||
|
|
||||||
/* Add padding and return the message digest. */
|
/* Add padding and return the message digest. */
|
||||||
|
|
||||||
STATIC void ICACHE_FLASH_ATTR SHA1Final(unsigned char digest[20], SHA1_CTX* context)
|
STATIC void ICACHE_FLASH_ATTR SHA1Final(unsigned char digest[20], SHA1_CTX* context) {
|
||||||
{
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned char finalcount[8];
|
unsigned char finalcount[8];
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
||||||
#if 0 /* untested "improvement" by DHR */
|
|
||||||
/* Convert context->count to a sequence of bytes
|
|
||||||
* in finalcount. Second element first, but
|
|
||||||
* big-endian order within element.
|
|
||||||
* But we do it all backwards.
|
|
||||||
*/
|
|
||||||
unsigned char *fcp = &finalcount[8];
|
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
uint32_t t = context->count[i];
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for (j = 0; j < 4; t >>= 8, j++)
|
|
||||||
*--fcp = (unsigned char) t;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
|
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
|
||||||
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
|
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
c = 0200;
|
c = 0200;
|
||||||
SHA1Update(context, &c, 1);
|
SHA1Update(context, &c, 1);
|
||||||
while ((context->count[0] & 504) != 448) {
|
while ((context->count[0] & 504) != 448) {
|
||||||
@@ -206,4 +145,3 @@ unsigned char c;
|
|||||||
memset(context, '\0', sizeof(*context));
|
memset(context, '\0', sizeof(*context));
|
||||||
memset(&finalcount, '\0', sizeof(finalcount));
|
memset(&finalcount, '\0', sizeof(finalcount));
|
||||||
}
|
}
|
||||||
/* ================ end of sha1.c ================ */
|
|
||||||
|
|||||||
@@ -13,15 +13,10 @@
|
|||||||
100% Public Domain
|
100% Public Domain
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SHA1_H_
|
#pragma once
|
||||||
#define SHA1_H_
|
|
||||||
|
|
||||||
#ifdef ESP32
|
|
||||||
#define ICACHE_FLASH_ATTR
|
#define ICACHE_FLASH_ATTR
|
||||||
#define STATIC static
|
#define STATIC static
|
||||||
#else
|
|
||||||
#define STATIC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t state[5];
|
uint32_t state[5];
|
||||||
@@ -33,7 +28,3 @@ STATIC void SHA1Transform(uint32_t state[5], uint8_t buffer[64]);
|
|||||||
STATIC void SHA1Init(SHA1_CTX* context);
|
STATIC void SHA1Init(SHA1_CTX* context);
|
||||||
STATIC void SHA1Update(SHA1_CTX* context, uint8_t* data, uint32_t len);
|
STATIC void SHA1Update(SHA1_CTX* context, uint8_t* data, uint32_t len);
|
||||||
STATIC void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
|
STATIC void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
|
||||||
|
|
||||||
#endif /* SHA1_H_ */
|
|
||||||
|
|
||||||
/* ================ end of sha1.h ================ */
|
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
#define TFT_NOP 0x00
|
|
||||||
|
|
||||||
#define TFT_INVOFF 0x20
|
|
||||||
#define TFT_INVON 0x21
|
|
||||||
|
|
||||||
#define TFT_CASET 0x2A
|
|
||||||
#define TFT_PASET 0x2B
|
|
||||||
#define TFT_RAMWR 0x2C
|
|
||||||
|
|
||||||
#define TFT_RAMRD 0x2E
|
|
||||||
#define TFT_IDXRD 0xDD
|
|
||||||
|
|
||||||
#define TFT_MADCTL 0x36
|
|
||||||
#define TFT_MAD_MY 0x80
|
|
||||||
#define TFT_MAD_MX 0x40
|
|
||||||
#define TFT_MAD_MV 0x20
|
|
||||||
#define TFT_MAD_ML 0x10
|
|
||||||
#define TFT_MAD_BGR 0x08
|
|
||||||
#define TFT_MAD_MH 0x04
|
|
||||||
#define TFT_MAD_RGB 0x00
|
|
||||||
|
|
||||||
#define ILI9341_SLPOUT 0x11
|
|
||||||
#define ILI9341_NORON 0x13
|
|
||||||
|
|
||||||
#define ILI9341_GAMMASET 0x26
|
|
||||||
#define ILI9341_DISPON 0x29
|
|
||||||
|
|
||||||
#define ILI9341_MADCTL 0x36
|
|
||||||
#define ILI9341_PIXFMT 0x3A
|
|
||||||
|
|
||||||
#define ILI9341_FRMCTR1 0xB1
|
|
||||||
#define ILI9341_DFUNCTR 0xB6
|
|
||||||
|
|
||||||
#define ILI9341_PWCTR1 0xC0
|
|
||||||
#define ILI9341_PWCTR2 0xC1
|
|
||||||
#define ILI9341_VMCTR1 0xC5
|
|
||||||
#define ILI9341_VMCTR2 0xC7
|
|
||||||
|
|
||||||
#define ILI9341_GMCTRP1 0xE0
|
|
||||||
#define ILI9341_GMCTRN1 0xE1
|
|
||||||
|
|
||||||
#define ILI9341_MADCTL_MY 0x80
|
|
||||||
#define ILI9341_MADCTL_MX 0x40
|
|
||||||
#define ILI9341_MADCTL_MV 0x20
|
|
||||||
#define ILI9341_MADCTL_ML 0x10
|
|
||||||
#define ILI9341_MADCTL_RGB 0x00
|
|
||||||
#define ILI9341_MADCTL_BGR 0x08
|
|
||||||
#define ILI9341_MADCTL_MH 0x04
|
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
writecommand(ILI9341_SLPOUT); //Exit Sleep
|
writecommand(ILI9341_SLPOUT); //Exit Sleep
|
||||||
|
|
||||||
end_tft_write();
|
end_tft_write();
|
||||||
delay(80);
|
delay(60);
|
||||||
begin_tft_write();
|
begin_tft_write();
|
||||||
|
|
||||||
writecommand(ILI9341_DISPON); //Display on
|
writecommand(ILI9341_DISPON); //Display on
|
||||||
|
|||||||
+237
-1846
File diff suppressed because it is too large
Load Diff
+86
-133
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define FONT_COUNT 7
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define SPI_FREQUENCY 7500000
|
#define SPI_FREQUENCY 7500000
|
||||||
@@ -52,11 +54,59 @@
|
|||||||
#define TFT_WIDTH 240
|
#define TFT_WIDTH 240
|
||||||
#define TFT_HEIGHT 320
|
#define TFT_HEIGHT 320
|
||||||
|
|
||||||
#include <ILI9341_Defines.h>
|
#define TFT_NOP 0x00
|
||||||
|
|
||||||
|
#define TFT_INVOFF 0x20
|
||||||
|
#define TFT_INVON 0x21
|
||||||
|
|
||||||
|
#define TFT_CASET 0x2A
|
||||||
|
#define TFT_PASET 0x2B
|
||||||
|
#define TFT_RAMWR 0x2C
|
||||||
|
|
||||||
|
#define TFT_RAMRD 0x2E
|
||||||
|
#define TFT_IDXRD 0xDD
|
||||||
|
|
||||||
|
#define TFT_MADCTL 0x36
|
||||||
|
#define TFT_MAD_MY 0x80
|
||||||
|
#define TFT_MAD_MX 0x40
|
||||||
|
#define TFT_MAD_MV 0x20
|
||||||
|
#define TFT_MAD_ML 0x10
|
||||||
|
#define TFT_MAD_BGR 0x08
|
||||||
|
#define TFT_MAD_MH 0x04
|
||||||
|
#define TFT_MAD_RGB 0x00
|
||||||
|
|
||||||
|
#define ILI9341_SLPOUT 0x11
|
||||||
|
#define ILI9341_NORON 0x13
|
||||||
|
|
||||||
|
#define ILI9341_GAMMASET 0x26
|
||||||
|
#define ILI9341_DISPON 0x29
|
||||||
|
|
||||||
|
#define ILI9341_MADCTL 0x36
|
||||||
|
#define ILI9341_PIXFMT 0x3A
|
||||||
|
|
||||||
|
#define ILI9341_FRMCTR1 0xB1
|
||||||
|
#define ILI9341_DFUNCTR 0xB6
|
||||||
|
|
||||||
|
#define ILI9341_PWCTR1 0xC0
|
||||||
|
#define ILI9341_PWCTR2 0xC1
|
||||||
|
#define ILI9341_VMCTR1 0xC5
|
||||||
|
#define ILI9341_VMCTR2 0xC7
|
||||||
|
|
||||||
|
#define ILI9341_GMCTRP1 0xE0
|
||||||
|
#define ILI9341_GMCTRN1 0xE1
|
||||||
|
|
||||||
|
#define ILI9341_MADCTL_MY 0x80
|
||||||
|
#define ILI9341_MADCTL_MX 0x40
|
||||||
|
#define ILI9341_MADCTL_MV 0x20
|
||||||
|
#define ILI9341_MADCTL_ML 0x10
|
||||||
|
#define ILI9341_MADCTL_RGB 0x00
|
||||||
|
#define ILI9341_MADCTL_BGR 0x08
|
||||||
|
#define ILI9341_MADCTL_MH 0x04
|
||||||
|
|
||||||
#include <pgmspace.h>
|
#include <pgmspace.h>
|
||||||
|
|
||||||
#include "soc/spi_reg.h"
|
#include "soc/spi_reg.h"
|
||||||
|
#include "soc/rtc.h"
|
||||||
#include "driver/spi_master.h"
|
#include "driver/spi_master.h"
|
||||||
#include "hal/gpio_ll.h"
|
#include "hal/gpio_ll.h"
|
||||||
|
|
||||||
@@ -78,7 +128,7 @@
|
|||||||
#define WR_L
|
#define WR_L
|
||||||
#define WR_H
|
#define WR_H
|
||||||
|
|
||||||
#define TFT_MISO -1
|
#define TFT_MISO 19
|
||||||
#define TFT_MOSI 23
|
#define TFT_MOSI 23
|
||||||
#define TFT_SCLK 18
|
#define TFT_SCLK 18
|
||||||
#define TFT_CS 5
|
#define TFT_CS 5
|
||||||
@@ -114,7 +164,7 @@
|
|||||||
// Write same value twice
|
// Write same value twice
|
||||||
#define tft_Write_32D(C) TFT_WRITE_BITS((uint16_t)((C)<<8 | (C)>>8)<<16 | (uint16_t)((C)<<8 | (C)>>8), 32)
|
#define tft_Write_32D(C) TFT_WRITE_BITS((uint16_t)((C)<<8 | (C)>>8)<<16 | (uint16_t)((C)<<8 | (C)>>8), 32)
|
||||||
|
|
||||||
#define tft_Read_8() transfer(0)
|
#define tft_Read_8() spi_transfer(0)
|
||||||
|
|
||||||
#define DAT8TO32(P) ( (uint32_t)P[0]<<8 | P[1] | P[2]<<24 | P[3]<<16 )
|
#define DAT8TO32(P) ( (uint32_t)P[0]<<8 | P[1] | P[2]<<24 | P[3]<<16 )
|
||||||
|
|
||||||
@@ -169,30 +219,7 @@
|
|||||||
// Convenient for 8-bit and 16-bit transparent sprites.
|
// Convenient for 8-bit and 16-bit transparent sprites.
|
||||||
#define TFT_TRANSPARENT 0x0120 // This is actually a dark green
|
#define TFT_TRANSPARENT 0x0120 // This is actually a dark green
|
||||||
|
|
||||||
// Default palette for 4-bit colour sprites
|
|
||||||
static const uint16_t default_4bit_palette[] PROGMEM = {
|
|
||||||
TFT_BLACK, // 0 ^
|
|
||||||
TFT_BROWN, // 1 |
|
|
||||||
TFT_RED, // 2 |
|
|
||||||
TFT_ORANGE, // 3 |
|
|
||||||
TFT_YELLOW, // 4 Colours 0-9 follow the resistor colour code!
|
|
||||||
TFT_GREEN, // 5 |
|
|
||||||
TFT_BLUE, // 6 |
|
|
||||||
TFT_PURPLE, // 7 |
|
|
||||||
TFT_DARKGREY, // 8 |
|
|
||||||
TFT_WHITE, // 9 v
|
|
||||||
TFT_CYAN, // 10 Blue+green mix
|
|
||||||
TFT_MAGENTA, // 11 Blue+red mix
|
|
||||||
TFT_MAROON, // 12 Darker red colour
|
|
||||||
TFT_DARKGREEN,// 13 Darker green colour
|
|
||||||
TFT_NAVY, // 14 Darker blue colour
|
|
||||||
TFT_PINK // 15
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef uint16_t (*getColorCallback)(uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
class TFT_eSPI { friend class TFT_eSprite;
|
class TFT_eSPI { friend class TFT_eSprite;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setSPISpeed(uint8_t speed_Mhz);
|
void setSPISpeed(uint8_t speed_Mhz);
|
||||||
TFT_eSPI(int16_t _W = TFT_WIDTH, int16_t _H = TFT_HEIGHT);
|
TFT_eSPI(int16_t _W = TFT_WIDTH, int16_t _H = TFT_HEIGHT);
|
||||||
@@ -206,7 +233,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
|
|
||||||
virtual int16_t height(),
|
virtual int16_t height(),
|
||||||
width();
|
width();
|
||||||
virtual uint16_t readPixel(int32_t x, int32_t y);
|
|
||||||
virtual void setWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye);
|
virtual void setWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye);
|
||||||
virtual void pushColor(uint16_t color);
|
virtual void pushColor(uint16_t color);
|
||||||
virtual void begin_nin_write();
|
virtual void begin_nin_write();
|
||||||
@@ -217,9 +243,7 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
void setAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h);
|
void setAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h);
|
||||||
void setViewport(int32_t x, int32_t y, int32_t w, int32_t h, bool vpDatum = true);
|
void setViewport(int32_t x, int32_t y, int32_t w, int32_t h, bool vpDatum = true);
|
||||||
void resetViewport();
|
void resetViewport();
|
||||||
bool clipWindow(int32_t* xs, int32_t* ys, int32_t* xe, int32_t* ye);
|
|
||||||
void pushColor(uint16_t color, uint32_t len);
|
void pushColor(uint16_t color, uint32_t len);
|
||||||
void pushColors(uint16_t *data, uint32_t len, bool swap = true);
|
|
||||||
void pushBlock(uint16_t color, uint32_t len);
|
void pushBlock(uint16_t color, uint32_t len);
|
||||||
void pushPixels(const void * data_in, uint32_t len);
|
void pushPixels(const void * data_in, uint32_t len);
|
||||||
void fillScreen(uint32_t color),
|
void fillScreen(uint32_t color),
|
||||||
@@ -229,22 +253,12 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
void drawCircleHelper(int32_t x, int32_t y, int32_t r, uint8_t cornername, uint32_t color),
|
void drawCircleHelper(int32_t x, int32_t y, int32_t r, uint8_t cornername, uint32_t color),
|
||||||
fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color),
|
fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color),
|
||||||
fillCircleHelper(int32_t x, int32_t y, int32_t r, uint8_t cornername, int32_t delta, uint32_t color),
|
fillCircleHelper(int32_t x, int32_t y, int32_t r, uint8_t cornername, int32_t delta, uint32_t color),
|
||||||
drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color),
|
|
||||||
fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color),
|
|
||||||
fillTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color);
|
fillTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color);
|
||||||
uint16_t drawPixel(int32_t x, int32_t y, uint32_t color, uint8_t alpha, uint32_t bg_color = 0x00FFFFFF);
|
uint16_t drawPixel(int32_t x, int32_t y, uint32_t color, uint8_t alpha, uint32_t bg_color = 0x00FFFFFF);
|
||||||
void drawArc(int32_t x, int32_t y, int32_t r, int32_t ir, uint32_t startAngle, uint32_t endAngle, uint32_t fg_color, uint32_t bg_color, bool smoothArc = true);
|
|
||||||
void drawSmoothCircle(int32_t x, int32_t y, int32_t r, uint32_t fg_color, uint32_t bg_color);
|
|
||||||
void fillSmoothCircle(int32_t x, int32_t y, int32_t r, uint32_t color, uint32_t bg_color = 0x00FFFFFF);
|
|
||||||
void drawSmoothRoundRect(int32_t x, int32_t y, int32_t r, int32_t ir, int32_t w, int32_t h, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF, uint8_t quadrants = 0xF);
|
|
||||||
void fillSmoothRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color, uint32_t bg_color = 0x00FFFFFF);
|
|
||||||
void drawWedgeLine(float ax, float ay, float bx, float by, float aw, float bw, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF);
|
|
||||||
void setSwapBytes(bool swap);
|
void setSwapBytes(bool swap);
|
||||||
bool getSwapBytes();
|
bool getSwapBytes();
|
||||||
void drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor),
|
void drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor),
|
||||||
drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor),
|
drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor);
|
||||||
setBitmapColor(uint16_t fgcolor, uint16_t bgcolor);
|
|
||||||
void setPivot(int16_t x, int16_t y);
|
|
||||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data);
|
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data);
|
||||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent);
|
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent);
|
||||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent);
|
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent);
|
||||||
@@ -254,17 +268,8 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint8_t *data, bool bpp8, uint16_t *cmap = nullptr);
|
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint8_t *data, bool bpp8, uint16_t *cmap = nullptr);
|
||||||
|
|
||||||
// Text rendering - value returned is the pixel width of the rendered text
|
// Text rendering - value returned is the pixel width of the rendered text
|
||||||
int16_t drawNumber(long intNumber, int32_t x, int32_t y, uint8_t font), // Draw integer using specified font number
|
|
||||||
drawNumber(long intNumber, int32_t x, int32_t y), // Draw integer using current font
|
|
||||||
|
|
||||||
// Decimal is the number of decimal places to render
|
|
||||||
// Use with setTextDatum() to position values on TFT, and setTextPadding() to blank old displayed values
|
|
||||||
drawFloat(float floatNumber, uint8_t decimal, int32_t x, int32_t y, uint8_t font), // Draw float using specified font number
|
|
||||||
drawFloat(float floatNumber, uint8_t decimal, int32_t x, int32_t y), // Draw float using current font
|
|
||||||
|
|
||||||
// Handle char arrays
|
// Handle char arrays
|
||||||
// Use with setTextDatum() to position string on TFT, and setTextPadding() to blank old displayed strings
|
int16_t drawString(const char *string, int32_t x, int32_t y, uint8_t font), // Draw string using specified font number
|
||||||
drawString(const char *string, int32_t x, int32_t y, uint8_t font), // Draw string using specified font number
|
|
||||||
drawString(const char *string, int32_t x, int32_t y), // Draw string using current font
|
drawString(const char *string, int32_t x, int32_t y), // Draw string using current font
|
||||||
drawString(const String& string, int32_t x, int32_t y, uint8_t font),// Draw string using specified font number
|
drawString(const String& string, int32_t x, int32_t y, uint8_t font),// Draw string using specified font number
|
||||||
drawString(const String& string, int32_t x, int32_t y); // Draw string using current font
|
drawString(const String& string, int32_t x, int32_t y); // Draw string using current font
|
||||||
@@ -274,34 +279,27 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
setCursor(int16_t x, int16_t y, uint8_t font);
|
setCursor(int16_t x, int16_t y, uint8_t font);
|
||||||
|
|
||||||
void setTextColor(uint16_t color), // Set character (glyph) color only (background not over-written)
|
void setTextColor(uint16_t color), // Set character (glyph) color only (background not over-written)
|
||||||
setTextColor(uint16_t fgcolor, uint16_t bgcolor, bool bgfill = false), // Set character (glyph) foreground and background colour, optional background fill for smooth fonts
|
setTextColor(uint16_t fgcolor, uint16_t bgcolor, bool bgfill = false); // Set character (glyph) foreground and background colour, optional background fill for smooth fonts
|
||||||
setTextSize(uint8_t size); // Set character size multiplier (this increases pixel size)
|
|
||||||
|
|
||||||
void setTextWrap(bool wrapX, bool wrapY = false); // Turn on/off wrapping of text in TFT width and/or height
|
|
||||||
|
|
||||||
void setTextDatum(uint8_t datum); // Set text datum position (default is top left), see Section 5 above
|
void setTextDatum(uint8_t datum); // Set text datum position (default is top left), see Section 5 above
|
||||||
|
|
||||||
void setTextPadding(uint16_t x_width); // Set text padding (background blanking) width in pixels
|
|
||||||
|
|
||||||
void setTextFont(uint8_t font); // Set the font number to use in future
|
void setTextFont(uint8_t font); // Set the font number to use in future
|
||||||
int16_t textWidth(const char *string, uint8_t font), // Returns pixel width of string in specified font
|
int16_t textWidth(const char *string, uint8_t font), // Returns pixel width of string in specified font
|
||||||
textWidth(const char *string), // Returns pixel width of string in current font
|
textWidth(const char *string), // Returns pixel width of string in current font
|
||||||
textWidth(const String& string, uint8_t font), // As above for String types
|
textWidth(const String& string, uint8_t font), // As above for String types
|
||||||
textWidth(const String& string),
|
textWidth(const String& string),
|
||||||
fontHeight(uint8_t font), // Returns pixel height of specified font
|
fontHeight(uint8_t font); // Returns pixel height of specified font
|
||||||
fontHeight(); // Returns pixel height of current font
|
inline int16_t fontHeight() { return fontHeight(textfont); }
|
||||||
|
|
||||||
// Used by library and Smooth font class to extract Unicode point codes from a UTF8 encoded string
|
// Used by library and Smooth font class to extract Unicode point codes from a UTF8 encoded string
|
||||||
uint16_t decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining),
|
uint16_t decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining),
|
||||||
decodeUTF8(uint8_t c);
|
decodeUTF8(uint8_t c);
|
||||||
|
|
||||||
void spiwrite(uint8_t); // legacy support only
|
|
||||||
void writecommand(uint8_t c); // Send an 8-bit command, function resets DC/RS high ready for data
|
void writecommand(uint8_t c); // Send an 8-bit command, function resets DC/RS high ready for data
|
||||||
void writedata(uint8_t d); // Send data with DC/RS set high
|
void writedata(uint8_t d); // Send data with DC/RS set high
|
||||||
|
|
||||||
// Colour conversion
|
// Colour conversion
|
||||||
// Convert 8-bit red, green and blue to 16 bits
|
// Convert 8-bit red, green and blue to 16 bits
|
||||||
uint16_t color565(uint8_t red, uint8_t green, uint8_t blue);
|
inline uint16_t color565(uint8_t r, uint8_t g, uint8_t b) { return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); }
|
||||||
|
|
||||||
// Alpha blend 2 colours, see generic "alphaBlend_Test" example
|
// Alpha blend 2 colours, see generic "alphaBlend_Test" example
|
||||||
// alpha = 0 = 100% background colour
|
// alpha = 0 = 100% background colour
|
||||||
@@ -311,12 +309,7 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
// 16-bit colour alphaBlend with alpha dither (dither reduces colour banding)
|
// 16-bit colour alphaBlend with alpha dither (dither reduces colour banding)
|
||||||
uint16_t alphaBlend(uint8_t alpha, uint16_t fgc, uint16_t bgc, uint8_t dither);
|
uint16_t alphaBlend(uint8_t alpha, uint16_t fgc, uint16_t bgc, uint8_t dither);
|
||||||
|
|
||||||
uint8_t spiBusyCheck = 0; // Number of ESP32 transfer buffers to check
|
inline void writeColor(uint16_t color, uint32_t len) { pushBlock(color, len); }
|
||||||
|
|
||||||
// Bare metal functions
|
|
||||||
void startWrite(); // Begin SPI transaction
|
|
||||||
void writeColor(uint16_t color, uint32_t len); // Deprecated, use pushBlock()
|
|
||||||
void endWrite(); // End SPI transaction
|
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
uint32_t textcolor, textbgcolor; // Text foreground and background colours
|
uint32_t textcolor, textbgcolor; // Text foreground and background colours
|
||||||
@@ -324,7 +317,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
uint32_t bitmap_fg, bitmap_bg; // Bitmap foreground (bit=1) and background (bit=0) colours
|
uint32_t bitmap_fg, bitmap_bg; // Bitmap foreground (bit=1) and background (bit=0) colours
|
||||||
|
|
||||||
uint8_t textfont, // Current selected font number
|
uint8_t textfont, // Current selected font number
|
||||||
textsize, // Current font size multiplier
|
|
||||||
textdatum, // Text reference datum
|
textdatum, // Text reference datum
|
||||||
rotation; // Display rotation (0-3)
|
rotation; // Display rotation (0-3)
|
||||||
|
|
||||||
@@ -351,24 +343,20 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
uint16_t maxDescent; // Maximum descent found in font
|
uint16_t maxDescent; // Maximum descent found in font
|
||||||
} fontMetrics;
|
} fontMetrics;
|
||||||
|
|
||||||
fontMetrics gFonts[7] = {
|
fontMetrics gFonts[FONT_COUNT] = {
|
||||||
{ nullptr, 0, 0, 0, 0, 0, 0, 0 },
|
|
||||||
{ nullptr, 0, 0, 0, 0, 0, 0, 0 },
|
|
||||||
{ nullptr, 0, 0, 0, 0, 0, 0, 0 },
|
|
||||||
{ nullptr, 0, 0, 0, 0, 0, 0, 0 },
|
|
||||||
{ nullptr, 0, 0, 0, 0, 0, 0, 0 },
|
|
||||||
{ nullptr, 0, 0, 0, 0, 0, 0, 0 },
|
|
||||||
{ nullptr, 0, 0, 0, 0, 0, 0, 0 }
|
{ nullptr, 0, 0, 0, 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
// These are for the metrics for each individual glyph (so we don't need to seek this in file and waste time)
|
// These are for the metrics for each individual glyph (so we don't need to seek this in file and waste time)
|
||||||
uint16_t* gUnicode[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //UTF-16 code, the codes are searched so do not need to be sequential
|
uint16_t* gUnicode[FONT_COUNT] = {NULL}; //UTF-16 code, the codes are searched so do not need to be sequential
|
||||||
uint8_t* gHeight[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cheight
|
uint8_t* gHeight[FONT_COUNT] = {NULL}; //cheight
|
||||||
uint8_t* gWidth[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cwidth
|
uint8_t* gWidth[FONT_COUNT] = {NULL}; //cwidth
|
||||||
uint8_t* gxAdvance[7] = {NULL, NULL, NULL, NULL, NULL, NULL}; //setWidth
|
uint8_t* gxAdvance[FONT_COUNT] = {NULL}; //setWidth
|
||||||
int16_t* gdY[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //topExtent
|
int16_t* gdY[FONT_COUNT] = {NULL}; //topExtent
|
||||||
int8_t* gdX[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //leftExtent
|
int8_t* gdX[FONT_COUNT] = {NULL}; //leftExtent
|
||||||
uint32_t* gBitmap[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //file pointer to greyscale bitmap
|
uint32_t* gBitmap[FONT_COUNT] = {NULL}; //file pointer to greyscale bitmap
|
||||||
|
|
||||||
|
bool fontOwned[FONT_COUNT] = {false};
|
||||||
|
|
||||||
uint8_t getTouchRaw(uint16_t *x, uint16_t *y);
|
uint8_t getTouchRaw(uint16_t *x, uint16_t *y);
|
||||||
uint16_t getTouchRawZ();
|
uint16_t getTouchRawZ();
|
||||||
@@ -378,33 +366,20 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
void calibrateTouch(uint16_t *data, uint32_t color_fg, uint32_t color_bg, uint8_t size);
|
void calibrateTouch(uint16_t *data, uint32_t color_fg, uint32_t color_bg, uint8_t size);
|
||||||
void setTouch(uint16_t *data);
|
void setTouch(uint16_t *data);
|
||||||
|
|
||||||
//--------------------------------------- private ------------------------------------//
|
void begin_tft_write();
|
||||||
|
void end_tft_write();
|
||||||
|
|
||||||
|
void begin_tft_read();
|
||||||
|
void end_tft_read();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void begin_tft_write() __attribute__((always_inline));
|
|
||||||
inline void end_tft_write() __attribute__((always_inline));
|
|
||||||
|
|
||||||
inline void begin_tft_read() __attribute__((always_inline));
|
|
||||||
inline void end_tft_read() __attribute__((always_inline));
|
|
||||||
|
|
||||||
void initBus();
|
void initBus();
|
||||||
|
|
||||||
void pushSwapBytePixels(const void* data_in, uint32_t len);
|
void pushSwapBytePixels(const void* data_in, uint32_t len);
|
||||||
|
|
||||||
void readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h);
|
void readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h);
|
||||||
|
|
||||||
uint8_t readByte();
|
void loadMetrics(uint8_t font);
|
||||||
|
|
||||||
void busDir(uint32_t mask, uint8_t mode);
|
|
||||||
|
|
||||||
void gpioMode(uint8_t gpio, uint8_t mode);
|
|
||||||
|
|
||||||
uint8_t sqrt_fraction(uint32_t num);
|
|
||||||
|
|
||||||
float wedgeLineDistance(float pax, float pay, float bax, float bay, float dr);
|
|
||||||
|
|
||||||
getColorCallback getColor = nullptr; // Smooth font callback function pointer
|
|
||||||
|
|
||||||
void loadMetrics(uint8_t font); // Function of Fear, which is Unhandled Exception, writing to 0x000000000
|
|
||||||
uint32_t readInt32();
|
uint32_t readInt32();
|
||||||
|
|
||||||
uint8_t* fontPtr = nullptr;
|
uint8_t* fontPtr = nullptr;
|
||||||
@@ -413,15 +388,10 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
uint8_t spi_write_speed;
|
uint8_t spi_write_speed;
|
||||||
//int32_t win_xe, win_ye; // Window end coords - not needed
|
|
||||||
|
|
||||||
int32_t _init_width, _init_height; // Display w/h as input, used by setRotation()
|
int32_t _init_width, _init_height; // Display w/h as input, used by setRotation()
|
||||||
int32_t _width, _height; // Display w/h as modified by current rotation
|
int32_t _width, _height; // Display w/h as modified by current rotation
|
||||||
int32_t addr_row, addr_col; // Window position - used to minimise window commands
|
int32_t addr_row, addr_col; // Window position - used to minimise window commands
|
||||||
|
|
||||||
int16_t _xPivot; // TFT x pivot point coordinate for rotated Sprites
|
|
||||||
int16_t _yPivot; // TFT x pivot point coordinate for rotated Sprites
|
|
||||||
|
|
||||||
// Viewport variables
|
// Viewport variables
|
||||||
int32_t _vpX, _vpY, _vpW, _vpH; // Note: x start, y start, x end + 1, y end + 1
|
int32_t _vpX, _vpY, _vpW, _vpH; // Note: x start, y start, x end + 1, y end + 1
|
||||||
int32_t _xDatum;
|
int32_t _xDatum;
|
||||||
@@ -431,11 +401,10 @@ uint8_t spi_write_speed;
|
|||||||
bool _vpDatum;
|
bool _vpDatum;
|
||||||
bool _vpOoB;
|
bool _vpOoB;
|
||||||
|
|
||||||
int32_t cursor_x, cursor_y, padX;
|
int32_t cursor_x, cursor_y;
|
||||||
int32_t bg_cursor_x;
|
int32_t bg_cursor_x;
|
||||||
int32_t last_cursor_x;
|
int32_t last_cursor_x;
|
||||||
|
|
||||||
bool isDigits;
|
|
||||||
bool textwrapX, textwrapY;
|
bool textwrapX, textwrapY;
|
||||||
bool _swapBytes;
|
bool _swapBytes;
|
||||||
|
|
||||||
@@ -459,17 +428,10 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
public:
|
public:
|
||||||
explicit TFT_eSprite(TFT_eSPI *tft);
|
explicit TFT_eSprite(TFT_eSPI *tft);
|
||||||
~TFT_eSprite();
|
~TFT_eSprite();
|
||||||
void* createSprite(int16_t width, int16_t height, uint8_t frames = 1);
|
void* createSprite(int16_t width = TFT_WIDTH, int16_t height = TFT_HEIGHT);
|
||||||
void* getPointer();
|
void* getPointer();
|
||||||
bool created();
|
inline bool created() {return _created; }
|
||||||
void deleteSprite();
|
void deleteSprite();
|
||||||
void* setColorDepth(int8_t b);
|
|
||||||
int8_t getColorDepth();
|
|
||||||
void createPalette(uint16_t *palette = nullptr, uint8_t colors = 16);
|
|
||||||
void createPalette(const uint16_t *palette = nullptr, uint8_t colors = 16);
|
|
||||||
void setPaletteColor(uint8_t index, uint16_t color);
|
|
||||||
uint16_t getPaletteColor(uint8_t index);
|
|
||||||
void setBitmapColor(uint16_t fg, uint16_t bg);
|
|
||||||
void drawPixel(int32_t x, int32_t y, uint32_t color);
|
void drawPixel(int32_t x, int32_t y, uint32_t color);
|
||||||
void fillSprite(uint32_t color),
|
void fillSprite(uint32_t color),
|
||||||
setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1),
|
setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1),
|
||||||
@@ -480,10 +442,8 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color),
|
drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color),
|
||||||
drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color),
|
drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color),
|
||||||
fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
||||||
uint16_t readPixel(int32_t x0, int32_t y0);
|
|
||||||
uint16_t readPixelValue(int32_t x, int32_t y);
|
|
||||||
void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, uint16_t *data, uint8_t sbpp = 0);
|
void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, uint16_t *data, uint8_t sbpp = 0);
|
||||||
void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, const uint16_t *data);
|
inline void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) { pushImage(x, y, w, h, (uint16_t*) data); }
|
||||||
void pushSprite(int32_t x, int32_t y);
|
void pushSprite(int32_t x, int32_t y);
|
||||||
void pushSprite(int32_t x, int32_t y, uint16_t transparent);
|
void pushSprite(int32_t x, int32_t y, uint16_t transparent);
|
||||||
bool pushSprite(int32_t tx, int32_t ty, int32_t sx, int32_t sy, int32_t sw, int32_t sh);
|
bool pushSprite(int32_t tx, int32_t ty, int32_t sx, int32_t sy, int32_t sw, int32_t sh);
|
||||||
@@ -492,23 +452,18 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
int16_t width(),
|
int16_t width(),
|
||||||
height();
|
height();
|
||||||
void drawGlyph(uint16_t code, uint16_t font);
|
void drawGlyph(uint16_t code, uint16_t font);
|
||||||
|
void copyFontFromTFT(uint8_t source, uint8_t destination);
|
||||||
|
void copyAllFontsFromTFT();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TFT_eSPI *_tft;
|
TFT_eSPI *_tft;
|
||||||
|
|
||||||
void* callocSprite(int16_t width, int16_t height, uint8_t frames = 1);
|
void* callocSprite(int16_t width, int16_t height);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
uint8_t _bpp; // bits per pixel (1, 4, 8 or 16)
|
|
||||||
uint16_t *_img; // pointer to 16-bit sprite
|
uint16_t *_img; // pointer to 16-bit sprite
|
||||||
uint8_t *_img8; // pointer to 1 and 8-bit sprite frame 1 or frame 2
|
|
||||||
uint8_t *_img4; // pointer to 4-bit sprite (uses color map)
|
|
||||||
uint8_t *_img8_1; // pointer to frame 1
|
|
||||||
uint8_t *_img8_2; // pointer to frame 2
|
|
||||||
|
|
||||||
uint16_t *_colorMap; // color map pointer: 16 entries, used with 4-bit color map.
|
|
||||||
|
|
||||||
int32_t _sinra; // Sine of rotation angle in fixed point
|
int32_t _sinra; // Sine of rotation angle in fixed point
|
||||||
int32_t _cosra; // Cosine of rotation angle in fixed point
|
int32_t _cosra; // Cosine of rotation angle in fixed point
|
||||||
@@ -521,13 +476,11 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
uint32_t _scolor;
|
uint32_t _scolor;
|
||||||
|
|
||||||
int32_t _iwidth, _iheight; // Sprite memory image bit width and height (swapped during rotations)
|
int32_t _iwidth, _iheight; // Sprite memory image bit width and height (swapped during rotations)
|
||||||
int32_t _dwidth, _dheight; // Real sprite width and height (for <8bpp Sprites)
|
int32_t _dwidth, _dheight; // Real sprite width and height
|
||||||
int32_t _bitwidth; // Sprite image bit width for drawPixel (for <8bpp Sprites, not swapped)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> static inline void transpose(T& a, T& b) { T t = a; a = b; b = t; }
|
template <typename T> static inline void transpose(T& a, T& b) { T t = a; a = b; b = t; }
|
||||||
template <typename A, typename F, typename B> static inline uint16_t fastBlend(A alpha, F fgc, B bgc)
|
template <typename A, typename F, typename B> static inline uint16_t fastBlend(A alpha, F fgc, B bgc) {
|
||||||
{
|
|
||||||
// Split out and blend 5-bit red and blue channels
|
// Split out and blend 5-bit red and blue channels
|
||||||
uint32_t rxb = bgc & 0xF81F;
|
uint32_t rxb = bgc & 0xF81F;
|
||||||
rxb += ((fgc & 0xF81F) - rxb) * (alpha >> 2) >> 6;
|
rxb += ((fgc & 0xF81F) - rxb) * (alpha >> 2) >> 6;
|
||||||
|
|||||||
@@ -1,674 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @file WC_AP_HTML.h
|
|
||||||
*
|
|
||||||
* HTML snippets to build the Access Point portal and the Parameters Portal.
|
|
||||||
*
|
|
||||||
* Written by Stuart Blair
|
|
||||||
*
|
|
||||||
* GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WC_AP_HTML
|
|
||||||
#define WC_AP_HTML ///< Define to stop re-inclusion
|
|
||||||
/*! \def char AP_HTTP_HEAD[] PROGMEM
|
|
||||||
Start of HTML output
|
|
||||||
*/
|
|
||||||
const char AP_HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>";
|
|
||||||
/*! \def AP_HTTP_STYLE[] PROGMEM
|
|
||||||
Style for our access point
|
|
||||||
*/
|
|
||||||
const char AP_HTTP_STYLE[] PROGMEM = "<style type=\"text/css\">h1 { font-weight: normal; } .msgbox { font-size:1.2rem; line-height: 1.8em; padding: 0.5em; background-color: #ddffff; border-left: 6px solid #ccc; margin-bottom:1em; } .c{text-align:center}div,input{padding:5px;font-size:1em}input{width:95%;margin-top:5px;margin-bottom:10px}body{text-align:center;font-family:verdana;}button{border:0;border-radius:.3rem;background-color:#1fa3ec;color:#fff;line-height:2.6rem;font-size:1.2rem;width:100%}.q{float:right;width:64px;text-align:right}.l{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==) no-repeat left center;background-size:1em;}.cfail,.cok{text-align:center; font-size:1.2rem; line-height: 2em; margin-top: 1em; padding: 0.7em; display:none;} .cfail{color: #FFFFFF;background-color: #ff8433;} .cok{ background-color: #6aff33;}</style>";
|
|
||||||
/** Scripts for our page */
|
|
||||||
const char AP_HTTP_SCRIPT[] PROGMEM = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>";
|
|
||||||
/** End of the header section and beginning of the body */
|
|
||||||
const char AP_HTTP_HEAD_END[] PROGMEM = "</head><body><div style='text-align:left;display:inline-block;min-width:260px;'>";
|
|
||||||
/** Start of our HTMl configuration Form */
|
|
||||||
const char AP_HTTP_PORTAL_OPTIONS[] PROGMEM = "<div class=\"msgbox\">Connect this device to a WiFi network. Select the option to find a WiFi network.</div><form action=\"/wifi\" method=\"get\"><button>Configure WiFi (Auto Scan)</button></form><br/><form action=\"/0wifi\" method=\"get\"><button style=\"background-color:#bbbbbb;\">Configure WiFi (Manual)</button></form><!--<br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/></form>-->";
|
|
||||||
/** HTML snippet for wifi scanning */
|
|
||||||
const char AP_HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> <span class='q {i}'>{r}%</span></div>";
|
|
||||||
/** HTML form for saving wifi connection details */
|
|
||||||
const char AP_HTTP_FORM_START[] PROGMEM ="<form method=\"post\" action=\"wifisave\"><label>Enter WiFi Name ('SSID'):</label><input id=\"s\" name=\"s\" length=32 placeholder=\"Example: Home_Network_2002\"><label>Enter WiFi Password:</label><input id=\"p\" name=\"p\" length=64 type=\"password\" placeholder=\"Password123\"><br/>";;
|
|
||||||
/** HTML snippet for our custom parameters */
|
|
||||||
const char AP_HTTP_FORM_PARAM[] PROGMEM = "<br/><input id='{i}' name='{n}' maxlength={l} placeholder='{p}' value='{v}' {c}>";
|
|
||||||
/** The end of our HTML Form */
|
|
||||||
const char AP_HTTP_FORM_END[] PROGMEM = "<br/><button type='submit'>Save and Connect</button></form>";
|
|
||||||
/** HTML snippet to recan for networks */
|
|
||||||
const char AP_HTTP_SCAN_LINK[] PROGMEM = "<br/><div class=\"c\"><a href=\"/wifi\">Re-scan</a></div>";
|
|
||||||
/** HTML snippet for saved confirmation */
|
|
||||||
// https://stackoverflow.com/questions/20760635/why-does-setting-xmlhttprequest-responsetype-before-calling-open-throw
|
|
||||||
// https://esprima.org/demo/validate.html
|
|
||||||
// https://javascript-minifier.com/
|
|
||||||
|
|
||||||
/* Use JavaScript to ping the ESP periodically @ the AP IP address.
|
|
||||||
* If it comes back as an AP again then we know the connection to the WiFi didn't work.
|
|
||||||
* We wait about 30 seconds to determine this outcome. This isn't 100% foolproof, but should be good enough.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
<script type="text/javascript">
|
|
||||||
function doPing() {
|
|
||||||
//if ( timeout_count > 20 ) {
|
|
||||||
if ( attempt_count > 20 ) { // wait about a minute
|
|
||||||
window.clearInterval(myPinger), document.getElementById("conn_ok").style.display = "block"
|
|
||||||
}
|
|
||||||
|
|
||||||
var o = new XMLHttpRequest;
|
|
||||||
o.onload = function() {
|
|
||||||
console.log(this.responseText), document.getElementById("conn_fail").style.display = "block", window.clearInterval(myPinger)
|
|
||||||
}, o.ontimeout = function(o) {
|
|
||||||
console.log("Timeout Counter is: " + timeout_count++)
|
|
||||||
}, o.open("GET", "/foo"), o.timeout = 1000, o.send(null), console.log("Ping counter is: " + attempt_count++)
|
|
||||||
}
|
|
||||||
|
|
||||||
attempt_count = 0;
|
|
||||||
timeout_count = 0;
|
|
||||||
var myPinger = window.setInterval(doPing, 3000);
|
|
||||||
|
|
||||||
</script>
|
|
||||||
*/
|
|
||||||
const char AP_HTTP_SAVED[] PROGMEM = "<div>Credentials Saved.<br />Attempting to connect to WiFi network. Please wait.... <br /><script type=\"text/javascript\">function doPing(){attempt_count>20&&(window.clearInterval(myPinger),document.getElementById(\"conn_ok\").style.display=\"block\");var t=new XMLHttpRequest;t.onload=function(){console.log(this.responseText),document.getElementById(\"conn_fail\").style.display=\"block\",window.clearInterval(myPinger)},t.ontimeout=function(t){console.log(\"Timeout Counter is: \"+timeout_count++)},t.open(\"GET\",\"/foo\"),t.timeout=1e3,t.send(null),console.log(\"Ping counter is: \"+attempt_count++)}attempt_count=0,timeout_count=0;var myPinger=window.setInterval(doPing,3e3);</script><div class=\"cok\" id=\"conn_ok\">Connected to {ap} !<br />You may now close this window. </div><div class=\"cfail\" id=\"conn_fail\">Failed to connect to {ap}!<br /><a href=\"/\">Click here</a> to try again.</div></div>";
|
|
||||||
/** End of the HTML page */
|
|
||||||
const char AP_HTTP_END[] PROGMEM = "</div></body></html>";
|
|
||||||
/** HTML snippet for our custom parameters portal form */
|
|
||||||
const char AP_HTTP_PORTAL_PARAM_OPTIONS[] PROGMEM = "<form action=\"/params\" method=\"get\"><button>Configure Parameters</button></form><br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/>";
|
|
||||||
/** HTML snippet for our custom parameters save */
|
|
||||||
const char AP_HTTP_FORM_PARAM_START[] PROGMEM ="<form method=\"get\" action=\"wifisave\">";
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,189 +0,0 @@
|
|||||||
/*!
|
|
||||||
@file WiFiConnect.h
|
|
||||||
|
|
||||||
This is the documentation for WiFiConnect for the Arduino platform.
|
|
||||||
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
|
||||||
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
|
||||||
via a web based interface and allows for additional user parameters.
|
|
||||||
|
|
||||||
You can view the project at <a href="https://github.com/smurf0969/WiFiConnect">https://github.com/smurf0969/WiFiConnect</a>.
|
|
||||||
Further information is also available in the project <a href="https://github.com/smurf0969/WiFiConnect/wiki">Wiki</a>.
|
|
||||||
|
|
||||||
This is a heavily customised version from the origional <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
|
||||||
developed by https://github.com/tzapu .
|
|
||||||
|
|
||||||
This library depends on <a href="https://github.com/esp8266/Arduino">
|
|
||||||
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
|
||||||
Please make sure you have installed the latest version before using this library.
|
|
||||||
|
|
||||||
Written by Stuart Blair.
|
|
||||||
|
|
||||||
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#ifndef WiFiConnect_h
|
|
||||||
#define WiFiConnect_h
|
|
||||||
#include <Arduino.h>
|
|
||||||
#if defined(ESP8266)
|
|
||||||
#include <ESP8266WiFi.h>
|
|
||||||
#include <ESP8266WebServer.h>
|
|
||||||
#else
|
|
||||||
#include <WiFi.h>
|
|
||||||
#include <FS.h>
|
|
||||||
using fs::FS;
|
|
||||||
#include <WebServer.h>
|
|
||||||
#endif
|
|
||||||
#include <DNSServer.h>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#if defined(ESP8266)
|
|
||||||
extern "C" {
|
|
||||||
#include "user_interface.h"
|
|
||||||
}
|
|
||||||
#define ESP_getChipId() (ESP.getChipId()) ///< Gets an ID from the chip
|
|
||||||
#else
|
|
||||||
#include <esp_wifi.h>
|
|
||||||
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())///< Gets an ID from the chip
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "WC_AP_HTML.h"
|
|
||||||
#include "WiFiConnectParam.h"
|
|
||||||
/** Options for how a access point should continue if no WiFi connected */
|
|
||||||
enum AP_Continue {
|
|
||||||
AP_NONE, ///< No action, continues to run code
|
|
||||||
AP_LOOP, ///< Stalls execution with an infinate loop
|
|
||||||
AP_RESTART, ///< Restarts the chip, allowing it to try to setup again. Handy for sensors when wifi is lost.
|
|
||||||
AP_RESET, ///< Same as AP_RESTART
|
|
||||||
AP_WAIT // Keep the AP and webserver running, sit quietly and be patient.
|
|
||||||
};
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Class that helps to connect to WiFi networks, that also has
|
|
||||||
captive portal web interface for configuration.
|
|
||||||
This is the base class for WiFiConntectOLED which displays
|
|
||||||
information on a OLED display.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
class WiFiConnect {
|
|
||||||
public:
|
|
||||||
/// Create WiFiConnect class
|
|
||||||
WiFiConnect();
|
|
||||||
|
|
||||||
boolean startConfigurationPortal();
|
|
||||||
boolean startConfigurationPortal(AP_Continue apcontinue);
|
|
||||||
boolean startConfigurationPortal(AP_Continue apcontinue, const char* apName, const char* apPassword = NULL, bool paramsMode = false);
|
|
||||||
|
|
||||||
boolean startParamsPortal();
|
|
||||||
boolean startParamsPortal(AP_Continue apcontinue);
|
|
||||||
boolean startParamsPortal(AP_Continue apcontinue, const char* apName, const char* apPassword = NULL);
|
|
||||||
|
|
||||||
void addParameter(WiFiConnectParam *p);
|
|
||||||
|
|
||||||
void setAPName(const char* apName);
|
|
||||||
const char* getAPName();
|
|
||||||
|
|
||||||
void resetSettings();
|
|
||||||
|
|
||||||
boolean autoConnect();
|
|
||||||
boolean autoConnect(const char* ssidName, const char* ssidPassword = NULL, WiFiMode_t acWiFiMode = WIFI_STA);
|
|
||||||
|
|
||||||
|
|
||||||
//sets a custom ip /gateway /subnet configuration
|
|
||||||
void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
|
||||||
//sets config for a static IP
|
|
||||||
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
|
||||||
|
|
||||||
//called when AP mode and config portal is started
|
|
||||||
void setAPCallback( void (*func)(WiFiConnect*) );
|
|
||||||
//called when settings have been changed and connection was successful
|
|
||||||
void setSaveConfigCallback( void (*func)() );
|
|
||||||
|
|
||||||
void setDebug(boolean isDebug);
|
|
||||||
|
|
||||||
void setRetryAttempts(int attempts);
|
|
||||||
void setConnectionTimeoutSecs(int timeout);
|
|
||||||
void setAPModeTimeoutMins(int mins);
|
|
||||||
|
|
||||||
boolean captivePortal();
|
|
||||||
|
|
||||||
//helpers
|
|
||||||
const char* statusToString(int state);
|
|
||||||
int getRSSIasQuality(int RSSI);
|
|
||||||
boolean isIp(String str);
|
|
||||||
String toStringIp(IPAddress ip);
|
|
||||||
virtual void displayTurnOFF(int ms = 5000); ///< Virtual method overriden in WiFiConnectOLED
|
|
||||||
virtual void displayLoop(); ///< Virtual method overriden in WiFiConnectOLED
|
|
||||||
virtual void displayON(); ///< Virtual method overriden in WiFiConnectOLED
|
|
||||||
protected:
|
|
||||||
boolean _debug = false; ///< Flag to determine wheter to output mesages or not
|
|
||||||
template <typename Generic>
|
|
||||||
void DEBUG_WC(Generic text);
|
|
||||||
virtual void displayConnecting(int attempt, int totalAttempts); ///< Virtual method overriden in WiFiConnectOLED
|
|
||||||
virtual void displayConnected(); ///< Virtual method overriden in WiFiConnectOLED
|
|
||||||
virtual void displayAP(); ///< Virtual method overriden in WiFiConnectOLED
|
|
||||||
virtual void displayParams(); ///< Virtual method overriden in WiFiConnectOLED
|
|
||||||
virtual void displayManualReset(); ///< Virtual method overriden in WiFiConnectOLED
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
int _retryAttempts = 3; ///< Number of attempts when trying to connect to WiFi network
|
|
||||||
int _connectionTimeoutSecs = 10; ///< How log to wait for the connection to succeed or fail
|
|
||||||
int _apTimeoutMins = 3; ///< The amount of minutes of inactivity before the access point exits it routine
|
|
||||||
// DNS server
|
|
||||||
const byte DNS_PORT = 53; ///< Standard DNS Port number
|
|
||||||
|
|
||||||
long _lastAPPage = 0; ///< The last time a page was accessed in the portal. Used for the inactivity timeout.
|
|
||||||
boolean _removeDuplicateAPs = true; ///< Flag to remove duplicate networks from scan results.
|
|
||||||
int _minimumQuality = 8; ///< The minimum netqork quality to be included in scan results.
|
|
||||||
int _paramsCount = 0; ///< The amount of custom parameters added via addParameter
|
|
||||||
boolean _readyToConnect = false; ///< Flag used in access point to determine if it should try to connect to the network.
|
|
||||||
String _ssid = " "; ///< Tempory holder for the network ssid
|
|
||||||
String _password = " "; ///< Tempory holder for the network password
|
|
||||||
|
|
||||||
WiFiConnectParam* _params[WiFiConnect_MAX_PARAMS]; ///< Array to hold custom parameters
|
|
||||||
|
|
||||||
std::unique_ptr<DNSServer> dnsServer; ///< DNS Server for captive portal to redirect to Access Point
|
|
||||||
#ifdef ESP8266
|
|
||||||
std::unique_ptr<ESP8266WebServer> server; ///< Web server for serving access point pages
|
|
||||||
#else
|
|
||||||
std::unique_ptr<WebServer> server; ///< Web server for serving access point pages
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char _apName[33] ; ///< Holder for the access point name
|
|
||||||
char _apPassword[65] ; ///< Holder for the access point password
|
|
||||||
|
|
||||||
IPAddress _ap_static_ip; ///< Variable for holding Static IP Address for the access point
|
|
||||||
IPAddress _ap_static_gw; ///< Variable for holding Static Gateway IP Address for the access point
|
|
||||||
IPAddress _ap_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the access point
|
|
||||||
IPAddress _sta_static_ip; ///< Variable for holding Static IP Address for the network connection
|
|
||||||
IPAddress _sta_static_gw; ///< Variable for holding Static Gateway IP Address for the network connection
|
|
||||||
IPAddress _sta_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the network connection
|
|
||||||
|
|
||||||
void (*_apcallback)(WiFiConnect*) = NULL;
|
|
||||||
void (*_savecallback)() = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void handleRoot();
|
|
||||||
void handleParamRoot();
|
|
||||||
void handleParams();
|
|
||||||
void handleWifi(boolean scan);
|
|
||||||
void handleWifiSave();
|
|
||||||
void handleInfo();
|
|
||||||
void handleReset();
|
|
||||||
void handle204();
|
|
||||||
void handleNotFound();
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
|
||||||
return obj->fromString(s);
|
|
||||||
}
|
|
||||||
auto optionalIPFromString(...) -> bool {
|
|
||||||
DEBUG_WC("NO fromString METHOD ON IPAddress, you need ESP8266 core 2.1.0 or newer for Custom IP configuration to work.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
/*!
|
|
||||||
@file WiFiConnectParam.cpp
|
|
||||||
|
|
||||||
WiFi Connection Manager with Captive Portal
|
|
||||||
|
|
||||||
Introduction
|
|
||||||
|
|
||||||
This is the documentation for WiFiConnect for the Arduino platform.
|
|
||||||
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
|
||||||
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
|
||||||
via a web based interface and allows for additional user parameters.
|
|
||||||
It can also display messages via a OLED screen see WiFiConnectOLED class.
|
|
||||||
|
|
||||||
This is a heavily customised version from the original <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
|
||||||
developed by https://github.com/tzapu .
|
|
||||||
|
|
||||||
Dependencies
|
|
||||||
|
|
||||||
This library depends on <a href="https://github.com/esp8266/Arduino">
|
|
||||||
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
|
||||||
Please make sure you have installed the latest version before using this library.
|
|
||||||
|
|
||||||
|
|
||||||
Written by Stuart Blair.
|
|
||||||
|
|
||||||
License
|
|
||||||
|
|
||||||
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "WiFiConnectParam.h"
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Class object initialiser
|
|
||||||
@param custom
|
|
||||||
Custom HTML to be displayed in the access point for this item.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
WiFiConnectParam::WiFiConnectParam(const char *custom) {
|
|
||||||
_id = NULL;
|
|
||||||
_placeholder = NULL;
|
|
||||||
_length = 0;
|
|
||||||
_value = NULL;
|
|
||||||
|
|
||||||
_customHTML = custom;
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Class object initialiser
|
|
||||||
@param id
|
|
||||||
The unique ID for the html input box markup for this item
|
|
||||||
@param placeholder
|
|
||||||
Text to be displayed as the input box placeholder for this item
|
|
||||||
@param defaultValue
|
|
||||||
Default text to be displayed in the input box for this item
|
|
||||||
@param length
|
|
||||||
The maximum input text length for this item
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length) {
|
|
||||||
init(id, placeholder, defaultValue, length, "");
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Class object initialiser
|
|
||||||
@param id
|
|
||||||
The unique ID for the html input box markup for this item
|
|
||||||
@param placeholder
|
|
||||||
Text to be displayed as the input box placeholder for this item
|
|
||||||
@param defaultValue
|
|
||||||
Default text to be displayed in the input box for this item
|
|
||||||
@param length
|
|
||||||
The maximum input text length for this item
|
|
||||||
@param custom
|
|
||||||
Custom HTML to be displayed in the access point for this item.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {
|
|
||||||
init(id, placeholder, defaultValue, length, custom);
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Initialiser method
|
|
||||||
@param id
|
|
||||||
The unique ID for the html input box markup for this item
|
|
||||||
@param placeholder
|
|
||||||
Text to be displayed as the input box placeholder for this item
|
|
||||||
@param defaultValue
|
|
||||||
Default text to be displayed in the input box for this item
|
|
||||||
@param length
|
|
||||||
The maximum input text length for this item
|
|
||||||
@param custom
|
|
||||||
Custom HTML to be displayed in the access point for this item.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
void WiFiConnectParam::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {
|
|
||||||
_id = id;
|
|
||||||
_placeholder = placeholder;
|
|
||||||
_length = length;
|
|
||||||
setValue(defaultValue);
|
|
||||||
|
|
||||||
_customHTML = custom;
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Method to change the current value of the item
|
|
||||||
@param newValue
|
|
||||||
The new string value for the item
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
void WiFiConnectParam::setValue(const char *newValue){
|
|
||||||
if(_length>0){
|
|
||||||
_value = new char[_length + 1];
|
|
||||||
for (int i = 0; i < _length; i++) {
|
|
||||||
_value[i] = 0;
|
|
||||||
}
|
|
||||||
if (newValue != NULL) {
|
|
||||||
strncpy(_value, newValue, _length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Function to get the current value of the item
|
|
||||||
@return The current value
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
const char* WiFiConnectParam::getValue() {
|
|
||||||
return _value;
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Function to get the current id of the item
|
|
||||||
@return The current id
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
const char* WiFiConnectParam::getID() {
|
|
||||||
return _id;
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Function to get the current placeholder text of the item
|
|
||||||
@return The current placeholder text
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
const char* WiFiConnectParam::getPlaceholder() {
|
|
||||||
return _placeholder;
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Function to get the maximum length allowed for the value of the item
|
|
||||||
@return The current maximum value length
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
int WiFiConnectParam::getValueLength() {
|
|
||||||
return _length;
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Function to get the current custom html markup of the item
|
|
||||||
@return The current custom html markup
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
const char* WiFiConnectParam::getCustomHTML() {
|
|
||||||
return _customHTML;
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*!
|
|
||||||
@file WiFiConnectParam.h
|
|
||||||
|
|
||||||
WiFi Connection Manager with Captive Portal
|
|
||||||
|
|
||||||
Introduction
|
|
||||||
|
|
||||||
This is the documentation for WiFiConnect for the Arduino platform.
|
|
||||||
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
|
||||||
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
|
||||||
via a web based interface and allows for additional user parameters.
|
|
||||||
It can also display messages via a OLED screen see WiFiConnectOLED class.
|
|
||||||
|
|
||||||
This is a heavily customised version from the original <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
|
||||||
developed by https://github.com/tzapu .
|
|
||||||
|
|
||||||
Dependencies
|
|
||||||
|
|
||||||
This library depends on <a href="https://github.com/esp8266/Arduino">
|
|
||||||
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
|
||||||
Please make sure you have installed the latest version before using this library.
|
|
||||||
|
|
||||||
|
|
||||||
Written by Stuart Blair.
|
|
||||||
|
|
||||||
License
|
|
||||||
|
|
||||||
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#ifndef WIFI_CONNECT_PARAM
|
|
||||||
#define WIFI_CONNECT_PARAM
|
|
||||||
|
|
||||||
#ifndef WiFiConnect_MAX_PARAMS
|
|
||||||
#define WiFiConnect_MAX_PARAMS 10 ///< The maximum size of the param array and how many custom parameters we may have
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@brief Class that stores a custom parameter
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
class WiFiConnectParam {
|
|
||||||
public:
|
|
||||||
WiFiConnectParam(const char *custom);
|
|
||||||
WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length);
|
|
||||||
WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
|
|
||||||
|
|
||||||
const char *getID();
|
|
||||||
const char *getValue();
|
|
||||||
const char *getPlaceholder();
|
|
||||||
int getValueLength();
|
|
||||||
const char *getCustomHTML();
|
|
||||||
void setValue(const char *newValue);
|
|
||||||
private:
|
|
||||||
const char *_id;
|
|
||||||
const char *_placeholder;
|
|
||||||
char *_value;
|
|
||||||
int _length;
|
|
||||||
const char *_customHTML;
|
|
||||||
|
|
||||||
void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
|
|
||||||
|
|
||||||
friend class WiFiConnect; ///< Declarion for WiFiConnect class
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "WifiConnect",
|
|
||||||
"version": "1.0",
|
|
||||||
"description": "A WiFi Manager for ESP8266 or ESP32",
|
|
||||||
"authors":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "Stuart Blair",
|
|
||||||
"email": "stuart@bfam.co.uk",
|
|
||||||
"maintainer": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"frameworks": "arduino",
|
|
||||||
"platforms": "espressif8266, espressif32"
|
|
||||||
}
|
|
||||||
+44
-23
@@ -1,65 +1,86 @@
|
|||||||
#include "NTPupdate.h"
|
#include "NTPupdate.h"
|
||||||
|
|
||||||
|
// Sends an NTP request packet to the specified server address
|
||||||
void sendNTPpacket(IPAddress &address) {
|
void sendNTPpacket(IPAddress &address) {
|
||||||
byte packetBuffer[NTP_PACKET_SIZE] = {0}; // Initialize buffer with zeros
|
byte packetBuffer[NTP_PACKET_SIZE] = {0}; // Initialize buffer with zeros
|
||||||
|
|
||||||
|
// Set NTP packet header fields as per NTP protocol
|
||||||
packetBuffer[0] = 0b11100011; // LI, Version, Mode
|
packetBuffer[0] = 0b11100011; // LI, Version, Mode
|
||||||
packetBuffer[2] = 6; // Polling interval
|
packetBuffer[2] = 6; // Polling interval
|
||||||
packetBuffer[3] = 0xEC; // Peer clock precision
|
packetBuffer[3] = 0xEC; // Peer clock precision
|
||||||
|
|
||||||
|
// Root Delay & Root Dispersion fields
|
||||||
packetBuffer[12] = 49;
|
packetBuffer[12] = 49;
|
||||||
packetBuffer[13] = 0x4E;
|
packetBuffer[13] = 0x4E;
|
||||||
packetBuffer[14] = 49;
|
packetBuffer[14] = 49;
|
||||||
packetBuffer[15] = 52;
|
packetBuffer[15] = 52;
|
||||||
|
|
||||||
|
// Send the NTP request to port 123 (NTP standard port)
|
||||||
Udp.beginPacket(address, 123);
|
Udp.beginPacket(address, 123);
|
||||||
Udp.write(packetBuffer, NTP_PACKET_SIZE);
|
Udp.write(packetBuffer, NTP_PACKET_SIZE);
|
||||||
Udp.endPacket();
|
Udp.endPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t getNtpTime() {
|
static uint8_t _ntpState = 0;
|
||||||
IPAddress ntpServerIP;
|
static unsigned long _ntpSendMs = 0;
|
||||||
byte packetBuffer[NTP_PACKET_SIZE];
|
static constexpr unsigned long NTP_TIMEOUT_MS = 1500;
|
||||||
|
|
||||||
|
// Starts an NTP request (non-blocking). Call ntpPoll() in loop to process the reply.
|
||||||
|
void NTPupdate() {
|
||||||
|
if (!wifi || WiFi.status() != WL_CONNECTED) {
|
||||||
|
NTPupdated = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress ntpServerIP;
|
||||||
|
|
||||||
|
// Clear any previously received UDP packets
|
||||||
while (Udp.parsePacket() > 0);
|
while (Udp.parsePacket() > 0);
|
||||||
|
|
||||||
if (!WiFi.hostByName(ntpServerName, ntpServerIP)) return 0;
|
// Resolve the NTP server's hostname to its IP address
|
||||||
|
if (!WiFi.hostByName(ntpServerName, ntpServerIP)) {
|
||||||
|
NTPupdated = false;
|
||||||
|
radio.rds.ctupdate = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send an NTP request and enter waiting state
|
||||||
sendNTPpacket(ntpServerIP);
|
sendNTPpacket(ntpServerIP);
|
||||||
|
_ntpState = 1;
|
||||||
|
_ntpSendMs = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ntpPoll() {
|
||||||
|
if (_ntpState != 1) return;
|
||||||
|
|
||||||
|
byte packetBuffer[NTP_PACKET_SIZE];
|
||||||
|
|
||||||
uint32_t startWait = millis();
|
|
||||||
while (millis() - startWait < 1500) {
|
|
||||||
if (Udp.parsePacket() >= NTP_PACKET_SIZE) {
|
if (Udp.parsePacket() >= NTP_PACKET_SIZE) {
|
||||||
Udp.read(packetBuffer, NTP_PACKET_SIZE);
|
Udp.read(packetBuffer, NTP_PACKET_SIZE);
|
||||||
|
|
||||||
|
// Extract "seconds since 1900" from the packet (bytes 40-43)
|
||||||
unsigned long secsSince1900 =
|
unsigned long secsSince1900 =
|
||||||
((unsigned long)packetBuffer[40] << 24) |
|
((unsigned long)packetBuffer[40] << 24) |
|
||||||
((unsigned long)packetBuffer[41] << 16) |
|
((unsigned long)packetBuffer[41] << 16) |
|
||||||
((unsigned long)packetBuffer[42] << 8) |
|
((unsigned long)packetBuffer[42] << 8) |
|
||||||
(unsigned long)packetBuffer[43];
|
(unsigned long)packetBuffer[43];
|
||||||
|
|
||||||
return secsSince1900 - 2208988800UL;
|
// Convert to UNIX epoch time (seconds since 1970)
|
||||||
}
|
time_t currentTime = secsSince1900 - 2208988800UL;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
rtc.setTime(currentTime);
|
||||||
}
|
set_time(currentTime, Timezone);
|
||||||
|
|
||||||
void NTPupdate() {
|
|
||||||
if (!wifi) {
|
|
||||||
NTPupdated = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t currentTime = getNtpTime();
|
|
||||||
|
|
||||||
if (currentTime) {
|
|
||||||
set_time(currentTime);
|
|
||||||
rtcset = true;
|
rtcset = true;
|
||||||
NTPupdated = true;
|
NTPupdated = true;
|
||||||
radio.rds.ctupdate = false;
|
radio.rds.ctupdate = false;
|
||||||
} else {
|
_ntpState = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timeout
|
||||||
|
if (millis() - _ntpSendMs >= NTP_TIMEOUT_MS) {
|
||||||
NTPupdated = false;
|
NTPupdated = false;
|
||||||
radio.rds.ctupdate = true;
|
radio.rds.ctupdate = true;
|
||||||
|
_ntpState = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -25,8 +25,7 @@ void RdsPiBuffer::clear(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
RdsPiBuffer::State RdsPiBuffer::getState(uint16_t value) {
|
RdsPiBuffer::State RdsPiBuffer::getState(uint16_t value) {
|
||||||
uint8_t count = 0;
|
uint8_t count = 0, correctCount = 0;
|
||||||
uint8_t correctCount = 0;
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < this->fill; i++) {
|
for (uint8_t i = 0; i < this->fill; i++) {
|
||||||
if (this->buff[i] == value) {
|
if (this->buff[i] == value) {
|
||||||
|
|||||||
+94
-96
@@ -24,13 +24,13 @@ void TEF6686::TestAFEON() {
|
|||||||
setMute();
|
setMute();
|
||||||
for (int x = 0; x < af_counter; x++) {
|
for (int x = 0; x < af_counter; x++) {
|
||||||
timing = 0;
|
timing = 0;
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 3, af[x].frequency);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 2, 3, af[x].frequency);
|
||||||
while (timing == 0 && !bitRead(timing, 15)) {
|
while (timing == 0 && !bitRead(timing, 15)) {
|
||||||
devTEF_Radio_Get_Quality_Status(&status, &aflevel, &afusn, &afwam, &afoffset, NULL, NULL, NULL);
|
devTEF_Radio_Get_Quality_Data(&status, &aflevel, &afusn, &afwam, &afoffset, NULL, NULL);
|
||||||
timing = lowByte(status);
|
timing = lowByte(status);
|
||||||
}
|
}
|
||||||
if (afoffset > -125 || afoffset < 125) {
|
if (afoffset > -125 || afoffset < 125) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 4, af[x].frequency);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 2, 4, af[x].frequency);
|
||||||
delay(187);
|
delay(187);
|
||||||
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
|
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ void TEF6686::TestAFEON() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 4, currentfreq);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 2, 4, currentfreq);
|
||||||
setUnMute();
|
setUnMute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +56,14 @@ uint16_t TEF6686::TestAF() {
|
|||||||
int16_t aflevel, afoffset, currentoffset, currentlevel;
|
int16_t aflevel, afoffset, currentoffset, currentlevel;
|
||||||
byte timing;
|
byte timing;
|
||||||
|
|
||||||
devTEF_Radio_Get_Quality_Status(&status, ¤tlevel, ¤tusn, ¤twam, ¤toffset, NULL, NULL, NULL);
|
devTEF_Radio_Get_Quality_Data(&status, ¤tlevel, ¤tusn, ¤twam, ¤toffset, NULL, NULL);
|
||||||
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
|
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
|
||||||
|
|
||||||
for (int x = 0; x < af_counter; x++) {
|
for (int x = 0; x < af_counter; x++) {
|
||||||
timing = 0;
|
timing = 0;
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 3, af[x].frequency);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 2, 3, af[x].frequency);
|
||||||
while (timing == 0 && !bitRead(timing, 15)) {
|
while (timing == 0 && !bitRead(timing, 15)) {
|
||||||
devTEF_Radio_Get_Quality_Status(&status, &aflevel, &afusn, &afwam, &afoffset, NULL, NULL, NULL);
|
devTEF_Radio_Get_Quality_Data(&status, &aflevel, &afusn, &afwam, &afoffset, NULL, NULL);
|
||||||
timing = lowByte(status);
|
timing = lowByte(status);
|
||||||
}
|
}
|
||||||
af[x].score = aflevel - afusn - afwam;
|
af[x].score = aflevel - afusn - afwam;
|
||||||
@@ -81,7 +81,7 @@ uint16_t TEF6686::TestAF() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (af_counter != 0 && af[highestIndex].afvalid && af[highestIndex].score > (currentlevel - currentusn - currentwam) && (af[highestIndex].score - (currentlevel - currentusn - currentwam)) >= 70) {
|
if (af_counter != 0 && af[highestIndex].afvalid && af[highestIndex].score > (currentlevel - currentusn - currentwam) && (af[highestIndex].score - (currentlevel - currentusn - currentwam)) >= 70) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 4, af[highestIndex].frequency);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 2, 4, af[highestIndex].frequency);
|
||||||
delay(187);
|
delay(187);
|
||||||
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
|
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
|
||||||
if (bitRead(rds.rdsStat, 9)) {
|
if (bitRead(rds.rdsStat, 9)) {
|
||||||
@@ -96,9 +96,9 @@ uint16_t TEF6686::TestAF() {
|
|||||||
af_counter = 0;
|
af_counter = 0;
|
||||||
} else {
|
} else {
|
||||||
af[highestIndex].afvalid = false;
|
af[highestIndex].afvalid = false;
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 4, currentfreq);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 2, 4, currentfreq);
|
||||||
}
|
}
|
||||||
} else devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 4, currentfreq);
|
} else devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 2, 4, currentfreq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return currentfreq;
|
return currentfreq;
|
||||||
@@ -109,7 +109,7 @@ void TEF6686::init(byte TEF) {
|
|||||||
Wire.setClock(400000);
|
Wire.setClock(400000);
|
||||||
Tuner_Reset();
|
Tuner_Reset();
|
||||||
|
|
||||||
while(devTEF_APPL_Get_Operation_Status() != 0) delay(2);
|
while(devTEF_APPL_Get_Operation_Status() != 0) delay(1);
|
||||||
|
|
||||||
uint32_t clock = 12000000;
|
uint32_t clock = 12000000;
|
||||||
|
|
||||||
@@ -130,106 +130,106 @@ void TEF6686::init(byte TEF) {
|
|||||||
|
|
||||||
while(devTEF_APPL_Get_Operation_Status() != 1) delay(2); // Wait for it to load
|
while(devTEF_APPL_Get_Operation_Status() != 1) delay(2); // Wait for it to load
|
||||||
|
|
||||||
if(clock != 9216000) devTEF_Set_Cmd(TEF_APPL, Cmd_Set_ReferenceClock, 6, (clock >> 16) & 0xffff, clock & 0xffff, (clock == 55466670) ? 1 : 0);
|
if(clock != 9216000) devTEF_Set_Cmd(TEF_APPL, Cmd_Set_ReferenceClock, 3, (clock >> 16) & 0xffff, clock & 0xffff, (clock == 55466670) ? 1 : 0);
|
||||||
devTEF_Set_Cmd(TEF_APPL, Cmd_Set_Activate, 2, 1); // Setup done, start radio
|
devTEF_Set_Cmd(TEF_APPL, Cmd_Set_Activate, 1, 1); // Setup done, start radio
|
||||||
|
|
||||||
while(devTEF_APPL_Get_Operation_Status() != 2) delay(2); // Wait for it to start
|
while(devTEF_APPL_Get_Operation_Status() != 2) delay(1); // Wait for it to start
|
||||||
|
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_LevelStep, 7, 0xffff, 0xffff, 0xffff, 0xffff, 0xfffc, 0xfff8, 0x0);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 3, 0, 360, 300);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Max, 2, 0, 4000);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_LowCut_Max, 2, 1, 60);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Time, 4, 60, 120, 100, 200);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Time, 4, 500, 2000, 200, 200);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Level, 3, 0, 600, 240);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Noise, 3, 0, 160, 140);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Mph, 3, 0, 160, 140);
|
||||||
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Max, 2, 0, 4000);
|
||||||
|
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Ana_Out, 2, 128, 1);
|
||||||
|
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Output_Source, 2, 128, 224);
|
||||||
Wire.setClock(old_clock);
|
Wire.setClock(old_clock);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 6, 0, 360, 300);
|
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Max, 4, 0, 4000);
|
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_LowCut_Max, 4, 0, 100);
|
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Time, 8, 60, 120, 100, 200);
|
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Time, 8, 500, 2000, 200, 200);
|
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Level, 6, 0, 600, 240);
|
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Noise, 6, 0, 160, 140);
|
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Mph, 6, 0, 160, 140);
|
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Max, 4, 0, 4000);
|
|
||||||
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Ana_Out, 4, 128, 1);
|
|
||||||
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Output_Source, 4, 128, 224);
|
|
||||||
|
|
||||||
uint16_t device;
|
uint16_t device = getIdentification(NULL, NULL);
|
||||||
getIdentification(&device, NULL, NULL);
|
|
||||||
|
|
||||||
if(device == 1 || device == 3) fullsearchrds = true;
|
if(device == 1 || device == 3) fullsearchrds = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::getIdentification(uint16_t *device, uint16_t *hw_version, uint16_t *sw_version) {
|
uint16_t TEF6686::getIdentification(uint16_t *hw_version, uint16_t *sw_version) {
|
||||||
uint8_t buf[6];
|
uint8_t buf[6];
|
||||||
devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Identification, buf, sizeof(buf));
|
devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Identification, buf, sizeof(buf));
|
||||||
|
|
||||||
if(device != NULL) *device = Convert8bto16b(buf);
|
|
||||||
if(hw_version != NULL) *hw_version = Convert8bto16b(buf + 2);
|
if(hw_version != NULL) *hw_version = Convert8bto16b(buf + 2);
|
||||||
if(sw_version != NULL) *sw_version = Convert8bto16b(buf + 4);
|
if(sw_version != NULL) *sw_version = Convert8bto16b(buf + 4);
|
||||||
|
return Convert8bto16b(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::power(bool mode) {
|
void TEF6686::power(bool mode) {
|
||||||
devTEF_Set_Cmd(TEF_APPL, Cmd_Set_OperationMode, 2, mode);
|
devTEF_Set_Cmd(TEF_APPL, Cmd_Set_OperationMode, 1, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::extendBW(bool yesno) {
|
void TEF6686::extendBW(bool yesno) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Bandwidth_Options, 2, (yesno ? 400 : 950));
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Bandwidth_Options, 1, (yesno ? 400 : 950));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::SetFreq(uint16_t frequency) {
|
void TEF6686::SetFreq(uint16_t frequency) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 1, frequency);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 2, 1, frequency);
|
||||||
currentfreq = ((frequency + 5) / 10) * 10;
|
currentfreq = ((frequency + 5) / 10) * 10;
|
||||||
currentfreq2 = frequency;
|
currentfreq2 = frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::SetFreqAM(uint16_t frequency) {
|
void TEF6686::SetFreqAM(uint16_t frequency) {
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Tune_To, 4, 1, frequency);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Tune_To, 2, 1, frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setOffset(int8_t offset) {
|
void TEF6686::setOffset(int8_t offset) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_LevelOffset, 2, (offset * 10) - 70);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_LevelOffset, 1, (offset * 10) - 70);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setAMOffset(int8_t offset) {
|
void TEF6686::setAMOffset(int8_t offset) {
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Set_LevelOffset, 2, (offset * 10) - 70);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Set_LevelOffset, 1, (offset * 10) - 70);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setFMBandw(uint16_t bandwidth) {
|
void TEF6686::setFMBandw(uint16_t bandwidth) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Bandwidth, 4, 0, bandwidth * 10);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Bandwidth, 2, 0, bandwidth * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setAMBandw(uint16_t bandwidth) {
|
void TEF6686::setAMBandw(uint16_t bandwidth) {
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Set_Bandwidth, 4, 0, bandwidth * 10);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Set_Bandwidth, 2, 0, bandwidth * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setAMCoChannel(uint16_t start, uint8_t level) {
|
void TEF6686::setAMCoChannel(uint16_t start, uint8_t level) {
|
||||||
uint8_t mode = 1;
|
uint8_t mode = 1;
|
||||||
if(start == 0) mode = 0;
|
if(start == 0) mode = 0;
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Set_CoChannelDet, 8, mode, 2, start * 10, 1000, level);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Set_CoChannelDet, 4, mode, 2, start * 10, 1000, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setSoftmuteAM(uint8_t mode) {
|
void TEF6686::setSoftmuteAM(uint8_t mode) {
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Set_Softmute_Max, 4, mode, 250);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Set_Softmute_Max, 2, mode, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setSoftmuteFM(uint8_t mode) {
|
void TEF6686::setSoftmuteFM(uint8_t mode) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Softmute_Max, 4, mode, 200);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Softmute_Max, 2, mode, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setAMNoiseBlanker(uint16_t start) {
|
void TEF6686::setAMNoiseBlanker(uint16_t start) {
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Set_NoiseBlanker, 4, (start == 0) ? 0 : 1, (start == 0) ? 1000 : start * 10);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Set_NoiseBlanker, 2, (start == 0) ? 0 : 1, (start == 0) ? 1000 : start * 10);
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Set_NoiseBlanker_Audio, 4, (start == 0) ? 0 : 1, 1000);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Set_NoiseBlanker_Audio, 2, (start == 0) ? 0 : 1, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setAMAttenuation(uint16_t start) {
|
void TEF6686::setAMAttenuation(uint16_t start) {
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Set_Antenna, 2, start * 10);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Set_Antenna, 1, start * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setFMABandw() {
|
void TEF6686::setFMABandw() {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Bandwidth, 4, 1, 3110);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Bandwidth, 2, 1, 3110);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setiMS(bool mph) {
|
void TEF6686::setiMS(bool mph) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_MphSuppression, 2, mph);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_MphSuppression, 1, mph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setEQ(bool eq) {
|
void TEF6686::setEQ(bool eq) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_ChannelEqualizer, 2, eq);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_ChannelEqualizer, 1, eq);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TEF6686::getStereoStatus() {
|
bool TEF6686::getStereoStatus() {
|
||||||
@@ -244,128 +244,127 @@ bool TEF6686::getStereoStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setMono(bool mono) {
|
void TEF6686::setMono(bool mono) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Min, 4, mono ? 2 : 0);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Min, 2, mono ? 2 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setVolume(int8_t volume) {
|
void TEF6686::setVolume(int8_t volume) {
|
||||||
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Volume, 2, volume * 10);
|
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Volume, 1, volume * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setMute() {
|
void TEF6686::setMute() {
|
||||||
mute = true;
|
mute = true;
|
||||||
if (mpxmode) devTEF_Set_Cmd(TEF_FM, Cmd_Set_Specials, 2, 0);
|
if (mpxmode) devTEF_Set_Cmd(TEF_FM, Cmd_Set_Specials, 1, 0);
|
||||||
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 2, 1);
|
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setUnMute() {
|
void TEF6686::setUnMute() {
|
||||||
mute = false;
|
mute = false;
|
||||||
if (mpxmode) devTEF_Set_Cmd(TEF_FM, Cmd_Set_Specials, 2, 1);
|
if (mpxmode) devTEF_Set_Cmd(TEF_FM, Cmd_Set_Specials, 1, 1);
|
||||||
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 2, 0);
|
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setAGC(uint8_t agc) {
|
void TEF6686::setAGC(uint8_t agc) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_RFAGC, 2, agc * 10);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_RFAGC, 1, agc * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setAMAGC(uint8_t agc) {
|
void TEF6686::setAMAGC(uint8_t agc) {
|
||||||
devTEF_Set_Cmd(TEF_AM, Cmd_Set_RFAGC, 2, agc * 10);
|
devTEF_Set_Cmd(TEF_AM, Cmd_Set_RFAGC, 1, agc * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setDeemphasis(RADIO_FM_DEEMPHASIS timeconstant) {
|
void TEF6686::setDeemphasis(RADIO_FM_DEEMPHASIS timeconstant) {
|
||||||
switch (timeconstant) {
|
switch (timeconstant) {
|
||||||
case DEEMPHASIS_50: devTEF_Set_Cmd(TEF_FM, Cmd_Set_Deemphasis, 2, 500); break;
|
case DEEMPHASIS_50: devTEF_Set_Cmd(TEF_FM, Cmd_Set_Deemphasis, 1, 500); break;
|
||||||
case DEEMPHASIS_75: devTEF_Set_Cmd(TEF_FM, Cmd_Set_Deemphasis, 2, 750); break;
|
case DEEMPHASIS_75: devTEF_Set_Cmd(TEF_FM, Cmd_Set_Deemphasis, 1, 750); break;
|
||||||
default: devTEF_Set_Cmd(TEF_FM, Cmd_Set_Deemphasis, 2, 0); break;
|
default: devTEF_Set_Cmd(TEF_FM, Cmd_Set_Deemphasis, 1, 0); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setAudio(uint8_t audio) {
|
void TEF6686::setAudio(uint8_t audio) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Specials, 2, audio);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Specials, 1, audio);
|
||||||
mpxmode = (audio != 0);
|
mpxmode = (audio != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setFMSI(uint8_t mode) {
|
void TEF6686::setFMSI(uint8_t mode) {
|
||||||
if(mode > 2) mode = 2;
|
if(mode > 2) mode = 2;
|
||||||
if(mode < 1) mode = 1;
|
if(mode < 1) mode = 1;
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StereoImprovement, 2, mode-1);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StereoImprovement, 1, mode-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setFMSI_Time(uint16_t attack, uint16_t decay) {
|
void TEF6686::setFMSI_Time(uint16_t attack, uint16_t decay) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StBandBlend_Time, 4, attack, decay);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StBandBlend_Time, 2, attack, decay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setFMSI_Gain(uint16_t band1, uint16_t band2, uint16_t band3, uint16_t band4) {
|
void TEF6686::setFMSI_Gain(uint16_t band1, uint16_t band2, uint16_t band3, uint16_t band4) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StBandBlend_Gain, 8, band1 * 10, band2 * 10, band3 * 10, band4 * 10);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StBandBlend_Gain, 4, band1 * 10, band2 * 10, band3 * 10, band4 * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setFMSI_Bias(int16_t band1, int16_t band2, int16_t band3, int16_t band4) {
|
void TEF6686::setFMSI_Bias(int16_t band1, int16_t band2, int16_t band3, int16_t band4) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StBandBlend_Bias, 8, band1 - 250, band2 - 250, band3 - 250, band4 - 250);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StBandBlend_Bias, 4, band1 - 250, band2 - 250, band3 - 250, band4 - 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setFMNoiseBlanker(uint16_t start) {
|
void TEF6686::setFMNoiseBlanker(uint16_t start) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_NoiseBlanker, 4, (start == 0) ? 0 : 1, (start == 0) ? 1000 : (start * 10));
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_NoiseBlanker, 2, (start == 0) ? 0 : 1, (start == 0) ? 1000 : (start * 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setStereoLevel(uint8_t start) {
|
void TEF6686::setStereoLevel(uint8_t start) {
|
||||||
if (start == 0) {
|
if (start == 0) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Level, 6, 0, start * 10, 60);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Level, 3, 0, start * 10, 60);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Noise, 6, 0, 240, 200);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Noise, 3, 0, 240, 200);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Mph, 6, 0, 240, 200);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Mph, 3, 0, 240, 200);
|
||||||
} else {
|
} else {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Level, 6, 3, start * 10, 60);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Level, 3, 3, start * 10, 60);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Noise, 6, 3, 240, 200);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Noise, 3, 3, 240, 200);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Mph, 6, 3, 240, 200);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Mph, 3, 3, 240, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setHighCutOffset(uint8_t start) {
|
void TEF6686::setHighCutOffset(uint8_t start) {
|
||||||
if (start == 0) {
|
if (start == 0) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Level, 6, 0, start * 10, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Level, 3, 0, start * 10, 300);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Noise, 6, 0, 360, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Noise, 3, 0, 360, 300);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 6, 0, 360, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 3, 0, 360, 300);
|
||||||
} else {
|
} else {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Level, 6, 3, start * 10, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Level, 3, 3, start * 10, 300);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Noise, 6, 3, 360, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Noise, 3, 3, 360, 300);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 6, 3, 360, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 3, 3, 360, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setHighCutLevel(uint16_t limit) {
|
void TEF6686::setHighCutLevel(uint16_t limit) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Max, 4, 1, limit * 100);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Max, 2, 1, limit * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setStHiBlendLevel(uint16_t limit) {
|
void TEF6686::setStHiBlendLevel(uint16_t limit) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Max, 4, 1, limit * 100);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Max, 2, 1, limit * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::setStHiBlendOffset(uint8_t start) {
|
void TEF6686::setStHiBlendOffset(uint8_t start) {
|
||||||
if (start == 0) {
|
if (start == 0) {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Level, 6, 0, start * 10, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Level, 3, 0, start * 10, 300);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Noise, 6, 0, 360, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Noise, 3, 0, 360, 300);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Mph, 6, 0, 360, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Mph, 3, 0, 360, 300);
|
||||||
} else {
|
} else {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Level, 6, 3, start * 10, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Level, 3, 3, start * 10, 300);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Noise, 6, 3, 360, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Noise, 3, 3, 360, 300);
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Mph, 6, 3, 360, 300);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Mph, 3, 3, 360, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::getStatus(int16_t *level, uint16_t *USN, uint16_t *WAM, int16_t *offset, uint16_t *bandwidth, uint16_t *modulation, int8_t *snr) {
|
void TEF6686::getStatus(int16_t *level, uint16_t *USN, uint16_t *WAM, int16_t *offset, uint16_t *bandwidth, uint16_t *audiolevel) {
|
||||||
devTEF_Radio_Get_Quality_Status(NULL, level, USN, WAM, offset, bandwidth, modulation, snr);
|
devTEF_Radio_Get_Quality_Data(NULL, level, USN, WAM, offset, bandwidth, audiolevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel, int16_t *offset, uint16_t *bandwidth, uint16_t *modulation, int8_t *snr) {
|
void TEF6686::getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel, int16_t *offset, uint16_t *bandwidth, uint16_t *audiolevel) {
|
||||||
uint8_t buf[14];
|
uint8_t buf[14];
|
||||||
devTEF_Get_Cmd(TEF_AM, Cmd_Get_Quality_Data, buf, sizeof(buf));
|
devTEF_Get_Cmd(TEF_AM, Cmd_Get_Quality_Status, buf, sizeof(buf));
|
||||||
if(level != NULL) *level = Convert8bto16b(buf + 2);
|
if(level != NULL) *level = Convert8bto16b(buf + 2);
|
||||||
if(noise != NULL) *noise = Convert8bto16b(buf + 4);
|
if(noise != NULL) *noise = Convert8bto16b(buf + 4);
|
||||||
if(cochannel != NULL) *cochannel = Convert8bto16b(buf + 6);
|
if(cochannel != NULL) *cochannel = Convert8bto16b(buf + 6);
|
||||||
if(offset != NULL) *offset = Convert8bto16b(buf + 8);
|
if(offset != NULL) *offset = Convert8bto16b(buf + 8);
|
||||||
if(bandwidth != NULL) *bandwidth = Convert8bto16b(buf + 10) / 10;
|
if(bandwidth != NULL) *bandwidth = Convert8bto16b(buf + 10) / 10;
|
||||||
if(modulation != NULL) *modulation = Convert8bto16b(buf + 12) / 10;
|
if(audiolevel != NULL) *audiolevel = Convert8bto16b(buf + 12) / 10;
|
||||||
if(level != NULL && *level < -200) *level = -200;
|
if(level != NULL && *level < -200) *level = -200;
|
||||||
if(level != NULL && *level > 1200) *level = 1200;
|
if(level != NULL && *level > 1200) *level = 1200;
|
||||||
if(snr != NULL) *snr = int(0.46222375 * (float)(*level) / 10 - 0.082495118 * (float)(*noise / 50) / 10) + 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::readRDS(byte showrdserrors) {
|
void TEF6686::readRDS(byte showrdserrors) {
|
||||||
@@ -449,7 +448,7 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
fs::File file;
|
fs::File file;
|
||||||
|
|
||||||
if (rds.region == 1 && SPIFFS.begin(true)) {
|
if (rds.region == 1 && SPIFFS.begin(true)) {
|
||||||
delay(2);
|
delay(1);
|
||||||
if (currentfreq2 < 9000) file = SPIFFS.open("/USA_87-90.csv");
|
if (currentfreq2 < 9000) file = SPIFFS.open("/USA_87-90.csv");
|
||||||
else if (currentfreq2 > 9000 && currentfreq2 < 9200) file = SPIFFS.open("/USA_90-92.csv");
|
else if (currentfreq2 > 9000 && currentfreq2 < 9200) file = SPIFFS.open("/USA_90-92.csv");
|
||||||
else if (currentfreq2 > 9200 && currentfreq2 < 9400) file = SPIFFS.open("/USA_92-94.csv");
|
else if (currentfreq2 > 9200 && currentfreq2 < 9400) file = SPIFFS.open("/USA_92-94.csv");
|
||||||
@@ -461,7 +460,6 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
else if (currentfreq2 > 10400 && currentfreq2 < 10600) file = SPIFFS.open("/USA_104-106.csv");
|
else if (currentfreq2 > 10400 && currentfreq2 < 10600) file = SPIFFS.open("/USA_104-106.csv");
|
||||||
else if (currentfreq2 > 10600) file = SPIFFS.open("/USA_106-108.csv");
|
else if (currentfreq2 > 10600) file = SPIFFS.open("/USA_106-108.csv");
|
||||||
|
|
||||||
delay(2);
|
|
||||||
if (file) {
|
if (file) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (file.available() && !isprint(file.peek())) {
|
while (file.available() && !isprint(file.peek())) {
|
||||||
@@ -1271,7 +1269,7 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
rds.offset = timeoffset;
|
rds.offset = timeoffset;
|
||||||
rtcset = true;
|
rtcset = true;
|
||||||
|
|
||||||
if (!NTPupdated) set_time(rdstime + timeoffset);
|
if (!NTPupdated) set_time(rdstime, timeoffset / 3600);
|
||||||
} else rds.hasCT = false;
|
} else rds.hasCT = false;
|
||||||
lastrdstime = rdstime;
|
lastrdstime = rdstime;
|
||||||
lasttimeoffset = timeoffset;
|
lasttimeoffset = timeoffset;
|
||||||
@@ -1449,7 +1447,7 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
if (offset == 13 && eon[eonIndex].pi == rds.rdsD) {
|
if (offset == 13 && eon[eonIndex].pi == rds.rdsD) {
|
||||||
eon[eonIndex].taset = true;
|
eon[eonIndex].taset = true;
|
||||||
eon[eonIndex].ta = bitRead(rds.rdsC, 0);
|
eon[eonIndex].ta = bitRead(rds.rdsC, 0);
|
||||||
eon[eonIndex].pty = (rds.rdsC >> 11) & 0xF;
|
eon[eonIndex].pty = (rds.rdsC >> 11) & 0x1F;
|
||||||
eon[eonIndex].ptyset = true;
|
eon[eonIndex].ptyset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1562,7 +1560,7 @@ void TEF6686::readRDS(byte showrdserrors) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::clearRDS() {
|
void TEF6686::clearRDS() {
|
||||||
devTEF_Set_Cmd(TEF_FM, Cmd_Set_RDS, 6, fullsearchrds ? 3 : 1, 1, 0);
|
devTEF_Set_Cmd(TEF_FM, Cmd_Set_RDS, 3, fullsearchrds ? 3 : 1, 1, 0);
|
||||||
rds.piBuffer.clear();
|
rds.piBuffer.clear();
|
||||||
rds.stationName = rds.stationText = rds.stationNameLong = "";
|
rds.stationName = rds.stationText = rds.stationNameLong = "";
|
||||||
rds.PTYN = rds.stationText32 = rds.RTContent1 = rds.RTContent2 = "";;
|
rds.PTYN = rds.stationText32 = rds.RTContent1 = rds.RTContent2 = "";;
|
||||||
@@ -1651,11 +1649,11 @@ void TEF6686::clearRDS() {
|
|||||||
|
|
||||||
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
||||||
auto was_muted = mute;
|
auto was_muted = mute;
|
||||||
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 2, 0);
|
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 1, 0);
|
||||||
devTEF_Radio_Set_Wavegen(1, amplitude, frequency);
|
devTEF_Radio_Set_Wavegen(1, amplitude, frequency);
|
||||||
delay(time);
|
delay(time);
|
||||||
devTEF_Radio_Set_Wavegen(0, 0, 0);
|
devTEF_Radio_Set_Wavegen(0, 0, 0);
|
||||||
if(was_muted) devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 2, 1);
|
if(was_muted) devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::RDScharConverter(const char* input, wchar_t* output, size_t size, bool underscore) {
|
void TEF6686::RDScharConverter(const char* input, wchar_t* output, size_t size, bool underscore) {
|
||||||
|
|||||||
+25
-24
@@ -2,53 +2,54 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
void devTEF_Set_Cmd(TEF_MODULE module, uint8_t cmd, uint16_t len, ...) {
|
void devTEF_Set_Cmd(TEF_MODULE module, uint8_t cmd, uint16_t len, ...) {
|
||||||
uint16_t i, temp;
|
if(len > 10) return;
|
||||||
uint8_t buf[20];
|
uint8_t buf[22];
|
||||||
va_list vArgs;
|
va_list vArgs;
|
||||||
va_start(vArgs, len);
|
va_start(vArgs, len);
|
||||||
buf[0] = module;
|
buf[0] = module;
|
||||||
buf[1] = cmd;
|
buf[1] = cmd;
|
||||||
buf[2] = 1;
|
buf[2] = 1;
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (uint16_t i = 0; i < len; i++) {
|
||||||
temp = va_arg(vArgs, int);
|
uint16_t temp = va_arg(vArgs, int);
|
||||||
buf[3 + i++] = High_16bto8b(temp);
|
buf[3 + 2*i] = High_16bto8b(temp);
|
||||||
buf[3 + i] = Low_16bto8b(temp);
|
buf[3 + 2*i + 1] = Low_16bto8b(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(vArgs);
|
va_end(vArgs);
|
||||||
Tuner_WriteBuffer(buf, len + 3);
|
Tuner_WriteBuffer(buf, len * 2 + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool devTEF_Get_Cmd(TEF_MODULE module, uint8_t cmd, uint8_t *receive, uint16_t len) {
|
bool devTEF_Get_Cmd(TEF_MODULE module, uint8_t cmd, uint8_t *receive, uint16_t len) {
|
||||||
uint8_t buf[3];
|
uint8_t buf[3] = {module, cmd, 1};
|
||||||
buf[0] = module;
|
|
||||||
buf[1] = cmd;
|
|
||||||
buf[2] = 1;
|
|
||||||
|
|
||||||
Tuner_WriteBuffer(buf, 3);
|
Tuner_WriteBuffer(buf, sizeof(buf));
|
||||||
return Tuner_ReadBuffer(receive, len);
|
return Tuner_ReadBuffer(receive, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t devTEF_APPL_Get_Operation_Status() {
|
uint8_t devTEF_APPL_Get_Operation_Status() {
|
||||||
uint8_t buf[2];
|
uint8_t buf[2];
|
||||||
while(!devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Operation_Status, buf, sizeof(buf))) delay(3);
|
while(!devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Operation_Status, buf, sizeof(buf))) delay(2);
|
||||||
return Convert8bto16b(buf);
|
return Convert8bto16b(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void devTEF_Radio_Get_Quality_Status(uint16_t *status, int16_t *level, uint16_t *usn, uint16_t *wam, int16_t *offset, uint16_t *bandwidth, uint16_t *mod, int8_t *snr) {
|
void devTEF_Radio_Get_Quality_Data(uint16_t *status, int16_t *level, uint16_t *usn, uint16_t *wam, int16_t *offset, uint16_t *bandwidth, uint16_t *audiolevel) {
|
||||||
uint8_t buf[14];
|
uint8_t buf[14];
|
||||||
devTEF_Get_Cmd(TEF_FM, Cmd_Get_Quality_Data, buf, sizeof(buf));
|
devTEF_Get_Cmd(TEF_FM, Cmd_Get_Quality_Data, buf, sizeof(buf));
|
||||||
|
|
||||||
|
int16_t _level = Convert8bto16b(buf + 2);
|
||||||
|
if (_level < -200) _level = -200;
|
||||||
|
if (_level > 1200) _level = 1200;
|
||||||
|
uint16_t _usn = Convert8bto16b(buf + 4);
|
||||||
|
uint16_t _wam = Convert8bto16b(buf + 6);
|
||||||
|
|
||||||
if(status != NULL) *status = Convert8bto16b(buf);
|
if(status != NULL) *status = Convert8bto16b(buf);
|
||||||
if(level != NULL) *level = Convert8bto16b(buf + 2);
|
if(level != NULL) *level = _level;
|
||||||
if(usn != NULL) *usn = Convert8bto16b(buf + 4);
|
if(usn != NULL) *usn = _usn;
|
||||||
if(wam != NULL) *wam = Convert8bto16b(buf + 6);
|
if(wam != NULL) *wam = _wam;
|
||||||
if(offset != NULL) *offset = Convert8bto16b(buf + 8);
|
if(offset != NULL) *offset = Convert8bto16b(buf + 8);
|
||||||
if(bandwidth != NULL) *bandwidth = Convert8bto16b(buf + 10) / 10;
|
if(bandwidth != NULL) *bandwidth = Convert8bto16b(buf + 10) / 10;
|
||||||
if(mod != NULL) *mod = Convert8bto16b(buf + 12) / 10;
|
if(audiolevel != NULL) *audiolevel = Convert8bto16b(buf + 12) / 10;
|
||||||
if (*level < -200) *level = -200;
|
|
||||||
if (*level > 1200) *level = 1200;
|
|
||||||
if(snr != NULL) *snr = int(0.46222375 * (float)(*level) / 10 - 0.082495118 * (float)(*usn) / 10) + 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void devTEF_Radio_Get_RDS_Status(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error) {
|
void devTEF_Radio_Get_RDS_Status(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error) {
|
||||||
@@ -74,7 +75,7 @@ void devTEF_Radio_Get_RDS_Data(uint16_t *status, uint16_t *A_block, uint16_t *B_
|
|||||||
}
|
}
|
||||||
|
|
||||||
void devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq) {
|
void devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq) {
|
||||||
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Input, 2, mode ? 240 : 0);
|
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Input, 1, mode ? 240 : 0);
|
||||||
if (mode) devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_WaveGen, 12, 5, 0, amplitude * 10, freq, amplitude * 10, freq);
|
if (mode) devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_WaveGen, 6, 5, 0, amplitude * 10, freq, amplitude * 10, freq);
|
||||||
else devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_WaveGen, 12, 0);
|
else devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_WaveGen, 6, 0);
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len) {
|
bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len) {
|
||||||
Wire.beginTransmission(TEF668X_ADDRESS);
|
Wire.beginTransmission(TEF668X_ADDRESS);
|
||||||
for (uint16_t i = 0; i < len; i++) Wire.write(buf[i]);
|
Wire.write(buf, len);
|
||||||
uint8_t r = Wire.endTransmission();
|
uint8_t r = Wire.endTransmission();
|
||||||
if (!Data_Accelerator) delay(1);
|
if (!Data_Accelerator) delay(1);
|
||||||
return (r == 0) ? true : false;
|
return (r == 0) ? true : false;
|
||||||
@@ -13,17 +13,15 @@ bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len) {
|
|||||||
|
|
||||||
bool Tuner_ReadBuffer(unsigned char *buf, uint16_t len) {
|
bool Tuner_ReadBuffer(unsigned char *buf, uint16_t len) {
|
||||||
Wire.requestFrom(TEF668X_ADDRESS, len);
|
Wire.requestFrom(TEF668X_ADDRESS, len);
|
||||||
if (Wire.available() == len) {
|
if (Wire.available() >= len) {
|
||||||
for (uint16_t i = 0; i < len; i++) buf[i] = Wire.read();
|
for (uint16_t i = 0; i < len; i++) buf[i] = Wire.read();
|
||||||
return true;
|
return true;
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) {
|
static void Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) {
|
||||||
unsigned char buf[24 + 1];
|
unsigned char buf[24 + 1];
|
||||||
uint16_t i, len;
|
uint16_t i, len;
|
||||||
uint16_t r;
|
|
||||||
buf[0] = 0x1b;
|
buf[0] = 0x1b;
|
||||||
|
|
||||||
while (size) {
|
while (size) {
|
||||||
@@ -33,7 +31,7 @@ static void Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) {
|
|||||||
for (i = 0; i < len; i++) buf[1 + i] = pgm_read_byte(&pLutBytes[i]);
|
for (i = 0; i < len; i++) buf[1 + i] = pgm_read_byte(&pLutBytes[i]);
|
||||||
pLutBytes += len;
|
pLutBytes += len;
|
||||||
|
|
||||||
if (1 != (r = Tuner_WriteBuffer(buf, len + 1))) break;
|
if(!Tuner_WriteBuffer(buf, len + 1)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,621 @@
|
|||||||
|
#include "WiFiConnect.h"
|
||||||
|
|
||||||
|
#include <SPIFFS.h>
|
||||||
|
|
||||||
|
#include "constants.h"
|
||||||
|
|
||||||
|
// ---- CSS for the captive portal ----
|
||||||
|
|
||||||
|
static const char TPL_STYLE[] PROGMEM =
|
||||||
|
"<style>"
|
||||||
|
"*{margin:0;padding:0;box-sizing:border-box}"
|
||||||
|
"body{font-family:-apple-system,'Segoe UI',system-ui,sans-serif;background:#202228;color:#fff;min-height:100vh}"
|
||||||
|
".w{max-width:440px;margin:0 auto;padding:20px 16px}"
|
||||||
|
".logo{display:block;margin:0 auto 8px;max-width:160px;height:auto}"
|
||||||
|
"h1{color:#5bd6ab;font-size:.92em;font-weight:600;text-transform:uppercase;letter-spacing:3px;"
|
||||||
|
"text-align:center;padding-bottom:12px;margin-bottom:18px;border-bottom:1px solid rgba(91,214,171,.15)}"
|
||||||
|
".msg{background:rgba(46,80,73,.3);border:1px solid rgba(60,127,106,.2);border-radius:12px;"
|
||||||
|
"padding:14px 18px;font-size:.88em;color:#a0a8b0;line-height:1.6;margin-bottom:20px;text-align:center}"
|
||||||
|
".cd{background:rgba(46,80,73,.12);border:1px solid rgba(60,127,106,.18);border-radius:14px;"
|
||||||
|
"padding:16px;margin-bottom:14px}"
|
||||||
|
".cd h2{font-size:.7em;color:#4db691;text-transform:uppercase;letter-spacing:1.5px;"
|
||||||
|
"margin-bottom:12px;font-weight:600;padding-left:10px;border-left:3px solid #4db691}"
|
||||||
|
"button,input[type=submit]{display:block;width:100%;padding:14px;background:#4db691;"
|
||||||
|
"color:#1a1c20;border:0;border-radius:12px;font-size:.92em;font-weight:600;"
|
||||||
|
"font-family:inherit;text-transform:uppercase;letter-spacing:.5px;cursor:pointer;"
|
||||||
|
"margin-bottom:8px;transition:background .2s}"
|
||||||
|
"button:hover{background:#5bd6ab}"
|
||||||
|
".alt{background:0 0;color:#8090a0;border:1px solid rgba(60,127,106,.3);"
|
||||||
|
"text-transform:none;font-weight:400;font-size:.82em;letter-spacing:0;padding:10px}"
|
||||||
|
".alt:hover{background:rgba(46,80,73,.2);color:#c0c8d0;border-color:#3c7f6a}"
|
||||||
|
"label{display:block;font-size:.7em;color:#6a7280;text-transform:uppercase;"
|
||||||
|
"letter-spacing:1px;margin:8px 0 4px;font-weight:500}"
|
||||||
|
"input[type=text],input[type=password]{display:block;width:100%;padding:11px 14px;"
|
||||||
|
"background:rgba(20,22,26,.5);border:1px solid rgba(60,127,106,.22);border-radius:10px;"
|
||||||
|
"color:#e0e4e8;font-size:.9em;font-family:inherit;margin-bottom:10px;outline:0;"
|
||||||
|
"transition:border .2s;-webkit-appearance:none}"
|
||||||
|
"input[type=text]:focus,input[type=password]:focus{border-color:#5bd6ab}"
|
||||||
|
"input::placeholder{color:#3a4250}"
|
||||||
|
".n{background:rgba(20,22,26,.35);border:1px solid rgba(60,127,106,.12);"
|
||||||
|
"border-radius:10px;padding:10px 12px;margin-bottom:5px;cursor:pointer;"
|
||||||
|
"display:flex;align-items:center;gap:10px;transition:border .2s}"
|
||||||
|
".n:hover{border-color:#3c7f6a}.n:active{border-color:#5bd6ab}"
|
||||||
|
".n span:first-child{color:#d0d4d8;flex:1;overflow:hidden;text-overflow:ellipsis;"
|
||||||
|
"white-space:nowrap;font-size:.88em}"
|
||||||
|
".q{display:flex;align-items:center;gap:5px;font-size:.72em;color:#505868;"
|
||||||
|
"font-family:ui-monospace,monospace;white-space:nowrap}"
|
||||||
|
".sig{display:flex;align-items:flex-end;gap:1px;height:12px}"
|
||||||
|
".sig i{display:block;width:3px;background:#1a2a24;border-radius:1px}"
|
||||||
|
".sig i:nth-child(1){height:3px}.sig i:nth-child(2){height:6px}"
|
||||||
|
".sig i:nth-child(3){height:9px}.sig i:nth-child(4){height:12px}"
|
||||||
|
".s1 i:nth-child(1){background:#f85149}"
|
||||||
|
".s2 i:nth-child(-n+2){background:#e8a838}"
|
||||||
|
".s3 i:nth-child(-n+3){background:#4db691}"
|
||||||
|
".s4 i{background:#5bd6ab}"
|
||||||
|
".lk{font-size:.55em;color:#505868;margin-left:1px}.lk::after{content:'\\1F512'}"
|
||||||
|
".ok,.fail{text-align:center;padding:18px;border-radius:14px;margin-top:16px;"
|
||||||
|
"display:none;line-height:1.6}"
|
||||||
|
".ok{background:rgba(46,80,73,.3);border:1px solid rgba(60,127,106,.2);color:#5bd6ab}"
|
||||||
|
".fail{background:rgba(74,32,32,.3);border:1px solid rgba(106,48,48,.2);color:#f85149}"
|
||||||
|
".fail a{color:#f85149}"
|
||||||
|
".ld::after{content:'';display:inline-block;width:22px;height:22px;"
|
||||||
|
"border:2px solid rgba(60,127,106,.2);border-top-color:#5bd6ab;"
|
||||||
|
"border-radius:50%;animation:r .7s linear infinite}"
|
||||||
|
"@keyframes r{to{transform:rotate(360deg)}}"
|
||||||
|
".ldw{text-align:center;padding:24px 0}"
|
||||||
|
".pt{color:#6a7280;font-size:.8em;margin:10px 0 2px;padding-top:8px;"
|
||||||
|
"border-top:1px solid rgba(60,127,106,.1)}"
|
||||||
|
".pw{position:relative}"
|
||||||
|
".pw input{padding-right:44px}"
|
||||||
|
".pw button{position:absolute;right:3px;top:3px;width:36px;height:calc(100% - 16px);"
|
||||||
|
"background:rgba(46,80,73,.3);border:0;border-radius:8px;padding:0;margin:0;"
|
||||||
|
"color:#506070;cursor:pointer;display:flex;align-items:center;justify-content:center;"
|
||||||
|
"text-transform:none;letter-spacing:0;font-size:.8em}"
|
||||||
|
".pw button:hover{color:#5bd6ab;background:rgba(46,80,73,.5)}"
|
||||||
|
".pw svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.5;"
|
||||||
|
"stroke-linecap:round;stroke-linejoin:round}"
|
||||||
|
".hn{display:flex;align-items:center;gap:8px;font-size:.8em;color:#506070;"
|
||||||
|
"margin:0 0 12px;cursor:pointer;font-weight:400;text-transform:none;letter-spacing:0}"
|
||||||
|
".hn input{width:auto;margin:0;accent-color:#4db691;-webkit-appearance:auto;appearance:auto}"
|
||||||
|
"</style>";
|
||||||
|
|
||||||
|
// ---- JavaScript for the WiFi configuration page (AJAX scan, password toggle, hidden network) ----
|
||||||
|
|
||||||
|
static const char TPL_WIFI_JS[] PROGMEM =
|
||||||
|
"function scan(){"
|
||||||
|
"var nl=document.getElementById('nl');"
|
||||||
|
"nl.innerHTML='<div class=\"ldw\"><span class=\"ld\"></span></div>';"
|
||||||
|
"var x=new XMLHttpRequest;"
|
||||||
|
"x.onload=function(){"
|
||||||
|
"try{var d=JSON.parse(x.responseText);var h='';"
|
||||||
|
"for(var i=0;i<d.n.length;i++){var n=d.n[i];"
|
||||||
|
"var sl=n.r<26?'s1':n.r<51?'s2':n.r<76?'s3':'s4';"
|
||||||
|
"h+='<div class=\"n\" onclick=\"sel(this)\"><span>'+esc(n.s)+'</span>'"
|
||||||
|
"+'<span class=\"q\"><span class=\"sig '+sl+'\"><i></i><i></i><i></i><i></i></span>'"
|
||||||
|
"+(n.e?'<span class=\"lk\"></span>':'')+'</span></div>';}"
|
||||||
|
"nl.innerHTML=h||'<div class=\"msg\">'+T.nn+'</div>';"
|
||||||
|
"}catch(e){nl.innerHTML='<div class=\"msg\">'+T.nn+'</div>';}};"
|
||||||
|
"x.onerror=function(){nl.innerHTML='<div class=\"msg\">'+T.nn+'</div>';};"
|
||||||
|
"x.open('GET','/scan');x.send();}"
|
||||||
|
"function esc(s){var d=document.createElement('div');"
|
||||||
|
"d.appendChild(document.createTextNode(s));return d.innerHTML;}"
|
||||||
|
"function sel(el){"
|
||||||
|
"var s=el.querySelector('span').textContent;"
|
||||||
|
"document.getElementById('s').value=s;"
|
||||||
|
"document.getElementById('hn').checked=false;"
|
||||||
|
"document.getElementById('p').focus();}"
|
||||||
|
"function togglePw(){"
|
||||||
|
"var p=document.getElementById('p');"
|
||||||
|
"p.type=p.type==='password'?'text':'password';}"
|
||||||
|
"function toggleHn(){"
|
||||||
|
"var c=document.getElementById('hn').checked;"
|
||||||
|
"var s=document.getElementById('s');"
|
||||||
|
"if(c){s.value='';s.focus();}}"
|
||||||
|
"window.addEventListener('load',scan);";
|
||||||
|
|
||||||
|
// ---- WiFiConnectParam implementation ----
|
||||||
|
|
||||||
|
WiFiConnectParam::WiFiConnectParam(const char *custom) {
|
||||||
|
_id = NULL;
|
||||||
|
_placeholder = NULL;
|
||||||
|
_length = 0;
|
||||||
|
_value = NULL;
|
||||||
|
_customHTML = custom;
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length) {
|
||||||
|
init(id, placeholder, defaultValue, length, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnectParam::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {
|
||||||
|
_id = id;
|
||||||
|
_placeholder = placeholder;
|
||||||
|
_length = length;
|
||||||
|
_value = NULL;
|
||||||
|
_customHTML = custom;
|
||||||
|
setValue(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnectParam::setValue(const char *newValue) {
|
||||||
|
if (_length > 0) {
|
||||||
|
delete[] _value;
|
||||||
|
_value = new char[_length + 1];
|
||||||
|
memset(_value, 0, _length + 1);
|
||||||
|
if (newValue != NULL) strncpy(_value, newValue, _length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* WiFiConnectParam::getValue() {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* WiFiConnectParam::getID() {
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* WiFiConnectParam::getPlaceholder() {
|
||||||
|
return _placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiConnectParam::getValueLength() {
|
||||||
|
return _length;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* WiFiConnectParam::getCustomHTML() {
|
||||||
|
return _customHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- WiFiConnect implementation ----
|
||||||
|
|
||||||
|
WiFiConnect::WiFiConnect() {
|
||||||
|
_apName[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnect::setAPName() {
|
||||||
|
String ssid = "TEF_" + String((uint32_t)ESP.getEfuseMac());
|
||||||
|
strcpy(_apName, ssid.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnect::addParameter(WiFiConnectParam *p) {
|
||||||
|
if (_paramsCount < WiFiConnect_MAX_PARAMS) {
|
||||||
|
_params[_paramsCount] = p;
|
||||||
|
_paramsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean WiFiConnect::autoConnect() {
|
||||||
|
return autoConnect(NULL, NULL, WIFI_STA);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean WiFiConnect::autoConnect(char const *ssidName, char const *ssidPassword, WiFiMode_t acWiFiMode) {
|
||||||
|
WiFi.mode(acWiFiMode);
|
||||||
|
|
||||||
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int c = 0;
|
||||||
|
while (c < RETRY_ATTEMPTS) {
|
||||||
|
long ms = millis();
|
||||||
|
|
||||||
|
if (ssidName == NULL || strlen(ssidName) == 0) {
|
||||||
|
wifi_config_t conf;
|
||||||
|
esp_wifi_get_config(WIFI_IF_STA, &conf);
|
||||||
|
String stored_ssid = String(reinterpret_cast<const char*>(conf.sta.ssid));
|
||||||
|
if (stored_ssid == "") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
WiFi.begin();
|
||||||
|
} else {
|
||||||
|
WiFi.begin(ssidName, ssidPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (millis() - (unsigned long)ms < ((unsigned int)CONNECTION_TIMEOUT_SECS * 1000)) {
|
||||||
|
int ws = WiFi.status();
|
||||||
|
if (ws == WL_CONNECTED) {
|
||||||
|
delay(500);
|
||||||
|
return true;
|
||||||
|
} else if (ws == WL_CONNECT_FAILED) {
|
||||||
|
delay(500);
|
||||||
|
} else {
|
||||||
|
delay(200);
|
||||||
|
yield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean WiFiConnect::startConfigurationPortal(int8_t cancelPin) {
|
||||||
|
delay(50);
|
||||||
|
|
||||||
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
|
WiFi.mode(WIFI_AP);
|
||||||
|
} else {
|
||||||
|
WiFi.mode(WIFI_AP_STA);
|
||||||
|
}
|
||||||
|
|
||||||
|
dnsServer.reset(new DNSServer());
|
||||||
|
server.reset(new WebServer(80));
|
||||||
|
|
||||||
|
setAPName();
|
||||||
|
WiFi.softAP(_apName);
|
||||||
|
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
/* Setup the DNS server redirecting all domains to the AP IP */
|
||||||
|
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
|
dnsServer->start(53, "*", WiFi.softAPIP());
|
||||||
|
|
||||||
|
/* Setup web pages: root, wifi config, scan API, logo, and not found */
|
||||||
|
server->on("/", std::bind(&WiFiConnect::handleRoot, this));
|
||||||
|
server->on("/wifi", std::bind(&WiFiConnect::handleWifi, this));
|
||||||
|
server->on("/scan", std::bind(&WiFiConnect::handleScan, this));
|
||||||
|
server->on("/wifisave", std::bind(&WiFiConnect::handleWifiSave, this));
|
||||||
|
server->on("/logo.png", std::bind(&WiFiConnect::handleLogo, this));
|
||||||
|
|
||||||
|
/* Captive portal detection endpoints — redirect to root to trigger popup */
|
||||||
|
server->on("/fwlink", std::bind(&WiFiConnect::handleRoot, this)); // Windows
|
||||||
|
server->on("/redirect", std::bind(&WiFiConnect::handleRoot, this)); // Windows 10+
|
||||||
|
server->on("/hotspot-detect.html", std::bind(&WiFiConnect::handleRoot, this)); // Apple iOS/macOS
|
||||||
|
server->on("/library/test/success.html", std::bind(&WiFiConnect::handleRoot, this)); // Apple legacy
|
||||||
|
server->on("/generate_204", std::bind(&WiFiConnect::handleRoot, this)); // Android
|
||||||
|
server->on("/gen_204", std::bind(&WiFiConnect::handleRoot, this)); // Android alt
|
||||||
|
server->on("/connecttest.txt", std::bind(&WiFiConnect::handleRoot, this)); // Windows 11
|
||||||
|
server->on("/ncsi.txt", std::bind(&WiFiConnect::handleRoot, this)); // Windows NCSI
|
||||||
|
|
||||||
|
server->onNotFound(std::bind(&WiFiConnect::handleNotFound, this));
|
||||||
|
|
||||||
|
server->begin();
|
||||||
|
|
||||||
|
if (cancelPin >= 0) {
|
||||||
|
while (digitalRead(cancelPin) == LOW) delay(10);
|
||||||
|
delay(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
_readyToConnect = false;
|
||||||
|
while (true) {
|
||||||
|
dnsServer->processNextRequest();
|
||||||
|
server->handleClient();
|
||||||
|
if (_readyToConnect) {
|
||||||
|
_readyToConnect = false;
|
||||||
|
|
||||||
|
if (autoConnect(_ssid.c_str(), _password.c_str(), WIFI_AP_STA)) {
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
delay(500);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cancelPin >= 0 && digitalRead(cancelPin) == LOW) {
|
||||||
|
delay(50); // debounce
|
||||||
|
if (digitalRead(cancelPin) == LOW) break;
|
||||||
|
}
|
||||||
|
yield();
|
||||||
|
}
|
||||||
|
|
||||||
|
server->close();
|
||||||
|
server.reset();
|
||||||
|
dnsServer.reset();
|
||||||
|
|
||||||
|
return (WiFi.status() == WL_CONNECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Page handlers ----
|
||||||
|
|
||||||
|
void WiFiConnect::handleRoot() {
|
||||||
|
if (captivePortal()) return;
|
||||||
|
|
||||||
|
String page = F("<!DOCTYPE html><html lang='en'><head>"
|
||||||
|
"<meta charset='utf-8'>"
|
||||||
|
"<meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'>"
|
||||||
|
"<title>");
|
||||||
|
page += textUI(311);
|
||||||
|
page += F("</title>");
|
||||||
|
page += FPSTR(TPL_STYLE);
|
||||||
|
page += F("</head><body><div class='w'>"
|
||||||
|
"<img class='logo' src='/logo.png' alt='FMDX'><h1>");
|
||||||
|
page += _apName;
|
||||||
|
page += F("</h1><div class='msg'>");
|
||||||
|
page += textUI(297);
|
||||||
|
page += F("</div><form action='/wifi' method='get'><button>");
|
||||||
|
page += textUI(298);
|
||||||
|
page += F("</button></form></div></body></html>");
|
||||||
|
|
||||||
|
server->sendHeader("Content-Length", String(page.length()));
|
||||||
|
server->send(200, "text/html", page);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnect::handleWifi() {
|
||||||
|
String page = F("<!DOCTYPE html><html lang='en'><head>"
|
||||||
|
"<meta charset='utf-8'>"
|
||||||
|
"<meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'>"
|
||||||
|
"<title>");
|
||||||
|
page += textUI(312);
|
||||||
|
page += F("</title>");
|
||||||
|
page += FPSTR(TPL_STYLE);
|
||||||
|
page += F("</head><body><div class='w'>"
|
||||||
|
"<img class='logo' src='/logo.png' alt='FMDX'><h1>");
|
||||||
|
page += _apName;
|
||||||
|
page += F("</h1>");
|
||||||
|
|
||||||
|
// ---- Networks card ----
|
||||||
|
page += F("<div class='cd'><h2>");
|
||||||
|
page += textUI(298);
|
||||||
|
page += F("</h2><div id='nl'><div class='ldw'><span class='ld'></span></div></div>"
|
||||||
|
"<button class='alt' onclick='scan()'>");
|
||||||
|
page += textUI(305);
|
||||||
|
page += F("</button></div>");
|
||||||
|
|
||||||
|
// ---- Connection form card ----
|
||||||
|
page += F("<div class='cd'><h2>");
|
||||||
|
page += textUI(304);
|
||||||
|
page += F("</h2><form method='post' action='wifisave'>");
|
||||||
|
|
||||||
|
// Hidden network toggle
|
||||||
|
page += F("<label class='hn'><input type='checkbox' id='hn' onchange='toggleHn()'> ");
|
||||||
|
page += textUI(299);
|
||||||
|
page += F("</label>");
|
||||||
|
|
||||||
|
// SSID field
|
||||||
|
page += F("<label>");
|
||||||
|
page += textUI(300);
|
||||||
|
page += F("</label><input type='text' id='s' name='s' maxlength='32' placeholder='");
|
||||||
|
page += textUI(301);
|
||||||
|
page += F("'>");
|
||||||
|
|
||||||
|
// Password field with SVG eye toggle
|
||||||
|
page += F("<label>");
|
||||||
|
page += textUI(302);
|
||||||
|
page += F("</label><div class='pw'><input type='password' id='p' name='p' maxlength='64' placeholder='");
|
||||||
|
page += textUI(303);
|
||||||
|
page += F("'><button type='button' onclick='togglePw()'>"
|
||||||
|
"<svg viewBox='0 0 24 24'><path d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/>"
|
||||||
|
"<circle cx='12' cy='12' r='3'/></svg></button></div>");
|
||||||
|
|
||||||
|
// Custom parameters
|
||||||
|
for (int i = 0; i < _paramsCount; i++) {
|
||||||
|
if (_params[i] == NULL) break;
|
||||||
|
|
||||||
|
if (_params[i]->getID() != NULL) {
|
||||||
|
char parLength[4];
|
||||||
|
snprintf(parLength, 4, "%d", _params[i]->getValueLength());
|
||||||
|
page += F("<input type='text' id='");
|
||||||
|
page += _params[i]->getID();
|
||||||
|
page += F("' name='");
|
||||||
|
page += _params[i]->getID();
|
||||||
|
page += F("' maxlength=");
|
||||||
|
page += parLength;
|
||||||
|
page += F(" placeholder='");
|
||||||
|
page += _params[i]->getPlaceholder();
|
||||||
|
page += F("' value='");
|
||||||
|
page += _params[i]->getValue();
|
||||||
|
page += F("' ");
|
||||||
|
page += _params[i]->getCustomHTML();
|
||||||
|
page += F(">");
|
||||||
|
} else {
|
||||||
|
page += F("<p class='pt'>");
|
||||||
|
page += _params[i]->getCustomHTML();
|
||||||
|
page += F("</p>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Submit button
|
||||||
|
page += F("<button type='submit'>");
|
||||||
|
page += textUI(304);
|
||||||
|
page += F("</button></form></div>");
|
||||||
|
|
||||||
|
// JavaScript: inject translated text, then functions
|
||||||
|
String nnText = textUI(313);
|
||||||
|
nnText.replace("'", "\\'");
|
||||||
|
page += F("<script>var T={nn:'");
|
||||||
|
page += nnText;
|
||||||
|
page += F("'};");
|
||||||
|
page += FPSTR(TPL_WIFI_JS);
|
||||||
|
page += F("</script></div></body></html>");
|
||||||
|
|
||||||
|
server->sendHeader("Content-Length", String(page.length()));
|
||||||
|
server->send(200, "text/html", page);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnect::handleScan() {
|
||||||
|
int n = WiFi.scanNetworks();
|
||||||
|
|
||||||
|
String json = F("{\"n\":[");
|
||||||
|
|
||||||
|
if (n > 0) {
|
||||||
|
// Sort by RSSI
|
||||||
|
int indices[n];
|
||||||
|
for (int i = 0; i < n; i++) indices[i] = i;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
for (int j = i + 1; j < n; j++) {
|
||||||
|
if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
|
||||||
|
std::swap(indices[i], indices[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicates (must be RSSI sorted)
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (indices[i] == -1) continue;
|
||||||
|
String cssid = WiFi.SSID(indices[i]);
|
||||||
|
for (int j = i + 1; j < n; j++) {
|
||||||
|
if (cssid == WiFi.SSID(indices[j])) indices[j] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool first = true;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (indices[i] == -1) continue;
|
||||||
|
int quality = getRSSIasQuality(WiFi.RSSI(indices[i]));
|
||||||
|
if (quality < MINIMUM_QUALITY) continue;
|
||||||
|
|
||||||
|
if (!first) json += ',';
|
||||||
|
first = false;
|
||||||
|
|
||||||
|
// Escape SSID for JSON
|
||||||
|
String ssid = WiFi.SSID(indices[i]);
|
||||||
|
ssid.replace("\\", "\\\\");
|
||||||
|
ssid.replace("\"", "\\\"");
|
||||||
|
|
||||||
|
json += F("{\"s\":\"");
|
||||||
|
json += ssid;
|
||||||
|
json += F("\",\"r\":");
|
||||||
|
json += String(quality);
|
||||||
|
json += F(",\"e\":");
|
||||||
|
json += (WiFi.encryptionType(indices[i]) != WIFI_AUTH_OPEN) ? '1' : '0';
|
||||||
|
json += '}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
json += F("]}");
|
||||||
|
server->send(200, "application/json", json);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnect::handleWifiSave() {
|
||||||
|
_ssid = server->arg("s").c_str();
|
||||||
|
_ssid.trim();
|
||||||
|
_password = server->arg("p").c_str();
|
||||||
|
_password.trim();
|
||||||
|
|
||||||
|
// Read custom parameters from form
|
||||||
|
for (int i = 0; i < _paramsCount; i++) {
|
||||||
|
if (_params[i] == NULL || _params[i]->getID() == NULL) continue;
|
||||||
|
String value = server->arg(_params[i]->getID()).c_str();
|
||||||
|
value.toCharArray(_params[i]->_value, _params[i]->_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
String page = F("<!DOCTYPE html><html lang='en'><head>"
|
||||||
|
"<meta charset='utf-8'>"
|
||||||
|
"<meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'>"
|
||||||
|
"<title>");
|
||||||
|
page += textUI(314);
|
||||||
|
page += F("</title>");
|
||||||
|
page += FPSTR(TPL_STYLE);
|
||||||
|
page += F("</head><body><div class='w'>"
|
||||||
|
"<img class='logo' src='/logo.png' alt='FMDX'><h1>");
|
||||||
|
page += _apName;
|
||||||
|
page += F("</h1><div class='cd'>");
|
||||||
|
|
||||||
|
// Connecting spinner
|
||||||
|
page += F("<div id='sp' style='text-align:center;padding:20px 0'>"
|
||||||
|
"<div class='ld'></div>"
|
||||||
|
"<p style='margin-top:14px;color:#ddd'>");
|
||||||
|
page += textUI(306);
|
||||||
|
page += F(" <strong style='color:#5bd6ab'>");
|
||||||
|
page += _ssid;
|
||||||
|
page += F("</strong> ...</p></div>");
|
||||||
|
|
||||||
|
// Polling script: polls /foo every 3s; if AP responds → fail, if 20 timeouts → success
|
||||||
|
page += F("<script>"
|
||||||
|
"var a=0,t=setInterval(function(){"
|
||||||
|
"if(a>20){clearInterval(t);document.getElementById('sp').style.display='none';"
|
||||||
|
"document.getElementById('ok').style.display='block';return}"
|
||||||
|
"var x=new XMLHttpRequest;"
|
||||||
|
"x.onload=function(){clearInterval(t);document.getElementById('sp').style.display='none';"
|
||||||
|
"document.getElementById('fl').style.display='block'};"
|
||||||
|
"x.ontimeout=function(){};"
|
||||||
|
"x.open('GET','/foo');x.timeout=1e3;x.send(null);a++},3e3);"
|
||||||
|
"</script>");
|
||||||
|
|
||||||
|
// Success message
|
||||||
|
page += F("<div class='ok' id='ok'>");
|
||||||
|
page += textUI(307);
|
||||||
|
page += F(" <strong>");
|
||||||
|
page += _ssid;
|
||||||
|
page += F("</strong>!<br>");
|
||||||
|
page += textUI(308);
|
||||||
|
page += F("</div>");
|
||||||
|
|
||||||
|
// Failure message
|
||||||
|
page += F("<div class='fail' id='fl'>");
|
||||||
|
page += textUI(309);
|
||||||
|
page += F(" <strong>");
|
||||||
|
page += _ssid;
|
||||||
|
page += F("</strong>.<br><a href='/'>");
|
||||||
|
page += textUI(310);
|
||||||
|
page += F("</a></div>");
|
||||||
|
|
||||||
|
page += F("</div></div></body></html>");
|
||||||
|
|
||||||
|
server->sendHeader("Content-Length", String(page.length()));
|
||||||
|
server->send(200, "text/html", page);
|
||||||
|
_readyToConnect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnect::handleLogo() {
|
||||||
|
fs::File file = SPIFFS.open("/logo.png", "r");
|
||||||
|
if (!file) {
|
||||||
|
server->send(404, "text/plain", "Logo not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
server->streamFile(file, "image/png");
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConnect::handleNotFound() {
|
||||||
|
if (captivePortal()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = "File Not Found\n\n";
|
||||||
|
message += "URI: ";
|
||||||
|
message += server->uri();
|
||||||
|
message += "\nMethod: ";
|
||||||
|
message += (server->method() == HTTP_GET) ? "GET" : "POST";
|
||||||
|
message += "\nArguments: ";
|
||||||
|
message += server->args();
|
||||||
|
message += "\n";
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < server->args(); i++) {
|
||||||
|
message += " " + server->argName(i) + ": " + server->arg(i) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||||
|
server->sendHeader("Pragma", "no-cache");
|
||||||
|
server->sendHeader("Expires", "-1");
|
||||||
|
server->sendHeader("Content-Length", String(message.length()));
|
||||||
|
server->send(404, "text/plain", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean WiFiConnect::captivePortal() {
|
||||||
|
if (!isIp(server->hostHeader())) {
|
||||||
|
String msg = "redirect\n";
|
||||||
|
server->sendHeader("Location", String("http://") + toStringIp(server->client().localIP()), true);
|
||||||
|
server->sendHeader("Content-Length", String(msg.length()));
|
||||||
|
server->send(302, "text/plain", msg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean WiFiConnect::isIp(String str) {
|
||||||
|
for (unsigned int i = 0; i < str.length(); i++) {
|
||||||
|
int c = str.charAt(i);
|
||||||
|
if (c != '.' && (c < '0' || c > '9')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String WiFiConnect::toStringIp(IPAddress ip) {
|
||||||
|
String res = "";
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
res += String((ip >> (8 * i)) & 0xFF) + ".";
|
||||||
|
}
|
||||||
|
res += String(((ip >> 8 * 3)) & 0xFF);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiConnect::getRSSIasQuality(int RSSI) {
|
||||||
|
int quality = 0;
|
||||||
|
if (RSSI <= -100) {
|
||||||
|
quality = 0;
|
||||||
|
} else if (RSSI >= -50) {
|
||||||
|
quality = 100;
|
||||||
|
} else {
|
||||||
|
quality = 2 * (RSSI + 100);
|
||||||
|
}
|
||||||
|
return quality;
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
#include <WebServer.h>
|
||||||
|
#include <DNSServer.h>
|
||||||
|
#include <esp_wifi.h>
|
||||||
|
#include <memory>
|
||||||
|
#include "core.h"
|
||||||
|
|
||||||
|
#define WiFiConnect_MAX_PARAMS 10
|
||||||
|
|
||||||
|
extern const char* textUI(uint16_t number);
|
||||||
|
|
||||||
|
class WiFiConnect;
|
||||||
|
class WiFiConnectParam {
|
||||||
|
public:
|
||||||
|
WiFiConnectParam(const char *custom);
|
||||||
|
|
||||||
|
WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length);
|
||||||
|
|
||||||
|
const char *getID();
|
||||||
|
const char *getValue();
|
||||||
|
const char *getPlaceholder();
|
||||||
|
int getValueLength();
|
||||||
|
const char *getCustomHTML();
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char *_id;
|
||||||
|
const char *_placeholder;
|
||||||
|
char *_value;
|
||||||
|
int _length;
|
||||||
|
const char *_customHTML;
|
||||||
|
|
||||||
|
void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
|
||||||
|
void setValue(const char *newValue);
|
||||||
|
|
||||||
|
friend class WiFiConnect;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WiFiConnect {
|
||||||
|
public:
|
||||||
|
WiFiConnect();
|
||||||
|
|
||||||
|
boolean autoConnect();
|
||||||
|
void addParameter(WiFiConnectParam *p);
|
||||||
|
boolean startConfigurationPortal(int8_t cancelPin);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static constexpr int RETRY_ATTEMPTS = 3;
|
||||||
|
static constexpr int CONNECTION_TIMEOUT_SECS = 10;
|
||||||
|
static constexpr int MINIMUM_QUALITY = 8;
|
||||||
|
|
||||||
|
int _paramsCount = 0;
|
||||||
|
boolean _readyToConnect = false;
|
||||||
|
String _ssid;
|
||||||
|
String _password;
|
||||||
|
|
||||||
|
WiFiConnectParam* _params[WiFiConnect_MAX_PARAMS];
|
||||||
|
|
||||||
|
std::unique_ptr<DNSServer> dnsServer;
|
||||||
|
std::unique_ptr<WebServer> server;
|
||||||
|
|
||||||
|
char _apName[33];
|
||||||
|
|
||||||
|
void setAPName();
|
||||||
|
|
||||||
|
boolean autoConnect(const char *ssidName, const char *ssidPassword, WiFiMode_t acWiFiMode);
|
||||||
|
|
||||||
|
void handleRoot();
|
||||||
|
void handleWifi();
|
||||||
|
void handleScan();
|
||||||
|
void handleWifiSave();
|
||||||
|
void handleLogo();
|
||||||
|
void handleNotFound();
|
||||||
|
|
||||||
|
boolean captivePortal();
|
||||||
|
boolean isIp(String str);
|
||||||
|
String toStringIp(IPAddress ip);
|
||||||
|
int getRSSIasQuality(int RSSI);
|
||||||
|
};
|
||||||
+303
-51
@@ -1,5 +1,7 @@
|
|||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
|
#include "graphics.h"
|
||||||
|
#include <ESPmDNS.h>
|
||||||
|
|
||||||
extern mem presets[];
|
extern mem presets[];
|
||||||
|
|
||||||
@@ -359,6 +361,11 @@ void Communication() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (data_str.startsWith("l") || data_str.startsWith("L")) printLogbookCSV();
|
} else if (data_str.startsWith("l") || data_str.startsWith("L")) printLogbookCSV();
|
||||||
|
else if(data_str.charAt(0) == '~' && data_str.charAt(1) == '/') {
|
||||||
|
MuteScreen(true);
|
||||||
|
i2c_pc_control = i2c_pc_control_init = true;
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RDSSPYUSB && Serial.available()) {
|
if (RDSSPYUSB && Serial.available()) {
|
||||||
@@ -423,8 +430,8 @@ void XDRGTKRoutine() {
|
|||||||
radio.setAGC(92);
|
radio.setAGC(92);
|
||||||
fmagc = 92;
|
fmagc = 92;
|
||||||
} else {
|
} else {
|
||||||
radio.setAMAGC(102);
|
radio.setAMAGC(100);
|
||||||
amagc = 102;
|
amagc = 100;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -508,35 +515,18 @@ void XDRGTKRoutine() {
|
|||||||
} case 'F': {
|
} case 'F': {
|
||||||
XDRBWset = atoi(buff + 1);
|
XDRBWset = atoi(buff + 1);
|
||||||
DataPrint("F" + String(XDRBWset) + "\n");
|
DataPrint("F" + String(XDRBWset) + "\n");
|
||||||
if (XDRBWset < 0) {
|
if (XDRBWset < 0) BWset = 0;
|
||||||
BWset = 0;
|
else if (XDRBWset < 16) BWset = XDRBWset + 1;
|
||||||
} else if (XDRBWset < 16) {
|
|
||||||
BWset = XDRBWset + 1;
|
|
||||||
}
|
|
||||||
doBW();
|
doBW();
|
||||||
break;
|
break;
|
||||||
} case 'G': {
|
} case 'G': {
|
||||||
byte offsetg = atoi(buff + 1);
|
uint8_t offsetg = strtoul(buff + 1, NULL, 2);
|
||||||
if (offsetg == 0) {
|
iMSset = (offsetg & 2) == 2;
|
||||||
iMSset = 1;
|
EQset = (offsetg & 1) == 1;
|
||||||
EQset = 1;
|
if (offsetg == 0) DataPrint("G00\n");
|
||||||
DataPrint("G00\n");
|
else if (offsetg == 2) DataPrint("G10\n");
|
||||||
}
|
else if (offsetg == 1) DataPrint("G01\n");
|
||||||
if (offsetg == 10) {
|
else if (offsetg == 3) DataPrint("G11\n");
|
||||||
iMSset = 1;
|
|
||||||
EQset = 0;
|
|
||||||
DataPrint("G10\n");
|
|
||||||
}
|
|
||||||
if (offsetg == 1) {
|
|
||||||
iMSset = 0;
|
|
||||||
EQset = 1;
|
|
||||||
DataPrint("G01\n");
|
|
||||||
}
|
|
||||||
if (offsetg == 11) {
|
|
||||||
iMSset = 0;
|
|
||||||
EQset = 0;
|
|
||||||
DataPrint("G11\n");
|
|
||||||
}
|
|
||||||
updateiMS();
|
updateiMS();
|
||||||
updateEQ();
|
updateEQ();
|
||||||
break;
|
break;
|
||||||
@@ -747,7 +737,7 @@ void XDRGTKRoutine() {
|
|||||||
doBW();
|
doBW();
|
||||||
break;
|
break;
|
||||||
case 'w': {
|
case 'w': {
|
||||||
unsigned int bwtemp = atoi(buff + 2);
|
uint32_t bwtemp = atoi(buff + 2);
|
||||||
switch (bwtemp) {
|
switch (bwtemp) {
|
||||||
case 0: BWset = 0; break;
|
case 0: BWset = 0; break;
|
||||||
case 56000: BWset = 1; break;
|
case 56000: BWset = 1; break;
|
||||||
@@ -770,7 +760,6 @@ void XDRGTKRoutine() {
|
|||||||
doBW();
|
doBW();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
radio.setMute();
|
radio.setMute();
|
||||||
if (!screenmute) tft.drawBitmap(249, 4, Speaker, 28, 24, PrimaryColor);
|
if (!screenmute) tft.drawBitmap(249, 4, Speaker, 28, 24, PrimaryColor);
|
||||||
@@ -787,7 +776,7 @@ void XDRGTKRoutine() {
|
|||||||
delay(5);
|
delay(5);
|
||||||
DataPrint(String(freq_scan * 10, DEC));
|
DataPrint(String(freq_scan * 10, DEC));
|
||||||
DataPrint(" = ");
|
DataPrint(" = ");
|
||||||
if (band < BAND_GAP) radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN); else radio.getStatusAM(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
|
if (band < BAND_GAP) radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus); else radio.getStatusAM(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus);
|
||||||
DataPrint(String((SStatus / 10) + 10, DEC));
|
DataPrint(String((SStatus / 10) + 10, DEC));
|
||||||
DataPrint(", ");
|
DataPrint(", ");
|
||||||
}
|
}
|
||||||
@@ -808,7 +797,7 @@ void XDRGTKRoutine() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} case 'W': {
|
} case 'W': {
|
||||||
unsigned int bwtemp = atoi(buff + 1);
|
uint32_t bwtemp = atoi(buff + 1);
|
||||||
switch (bwtemp) {
|
switch (bwtemp) {
|
||||||
case 0: BWset = 0; break;
|
case 0: BWset = 0; break;
|
||||||
case 56000: BWset = 1; break;
|
case 56000: BWset = 1; break;
|
||||||
@@ -900,37 +889,300 @@ void passwordcrypt() {
|
|||||||
cryptedpassword = String(sha1(salt));
|
cryptedpassword = String(sha1(salt));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tryWiFi() {
|
static uint8_t _wifiConnState = 0; // 0=idle, 1=connecting
|
||||||
if (!setupmode && wifi) {
|
static unsigned long _wifiConnMs = 0;
|
||||||
tft.drawRoundRect(1, 20, 319, 180, 5, ActiveColor);
|
static uint8_t _wifiConnRetry = 0;
|
||||||
tft.fillRoundRect(3, 22, 315, 176, 5, BackgroundColor);
|
static bool _wifiServicesUp = false;
|
||||||
Infoboxprint(textUI(52));
|
static bool _wifiHandlersSet = false;
|
||||||
}
|
static constexpr uint8_t WIFI_MAX_RETRIES = 3;
|
||||||
if (wifi) {
|
static constexpr unsigned long WIFI_TIMEOUT_MS = 10000; // 10s per attempt
|
||||||
if (wc.autoConnect()) {
|
static constexpr unsigned long WIFI_RECONNECT_MS = 30000; // 30s between reconnect cycles
|
||||||
|
|
||||||
|
static void wifiStartServices() {
|
||||||
Server.begin();
|
Server.begin();
|
||||||
Udp.begin(9031);
|
Udp.begin(9031);
|
||||||
|
if (!_wifiHandlersSet) {
|
||||||
webserver.on("/", handleRoot);
|
webserver.on("/", handleRoot);
|
||||||
webserver.on("/downloadCSV", HTTP_GET, handleDownloadCSV);
|
webserver.on("/downloadCSV", HTTP_GET, handleDownloadCSV);
|
||||||
webserver.on("/logo.png", handleLogo);
|
webserver.on("/logo.png", handleLogo);
|
||||||
|
_wifiHandlersSet = true;
|
||||||
|
}
|
||||||
webserver.begin();
|
webserver.begin();
|
||||||
|
MDNS.begin("tef");
|
||||||
NTPupdate();
|
NTPupdate();
|
||||||
remoteip = IPAddress(WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient);
|
remoteip = IPAddress(WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient);
|
||||||
if (!setupmode) tftPrint(ACENTER, textUI(54), 155, 128, InsignificantColor, InsignificantColorSmooth, 28);
|
_wifiServicesUp = true;
|
||||||
} else {
|
if (menu && menupage == CONNECTIVITY) BuildMenu();
|
||||||
if (!setupmode) tftPrint(ACENTER, textUI(53), 155, 128, SignificantColor, SignificantColorSmooth, 28);
|
}
|
||||||
|
|
||||||
|
static void wifiStopServices() {
|
||||||
|
_wifiServicesUp = false;
|
||||||
|
MDNS.end();
|
||||||
Server.end();
|
Server.end();
|
||||||
webserver.stop();
|
webserver.stop();
|
||||||
Udp.stop();
|
Udp.stop();
|
||||||
WiFi.mode(WIFI_OFF);
|
|
||||||
wifi = false;
|
|
||||||
XDRGTKTCP = false;
|
|
||||||
RDSSPYTCP = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tryWiFi() {
|
||||||
|
if (!wifi) {
|
||||||
|
_wifiConnState = 0;
|
||||||
|
if (_wifiServicesUp) wifiStopServices();
|
||||||
|
WiFi.mode(WIFI_OFF);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
_wifiConnState = 0;
|
||||||
|
if (!_wifiServicesUp) wifiStartServices();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
WiFi.begin();
|
||||||
|
_wifiConnState = 1;
|
||||||
|
_wifiConnMs = millis();
|
||||||
|
_wifiConnRetry = 0;
|
||||||
|
_wifiServicesUp = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void wifiPoll() {
|
||||||
|
if (!wifi) return;
|
||||||
|
|
||||||
|
if (_wifiConnState == 1) {
|
||||||
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
_wifiConnState = 0;
|
||||||
|
wifiStartServices();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (millis() - _wifiConnMs >= WIFI_TIMEOUT_MS) {
|
||||||
|
_wifiConnRetry++;
|
||||||
|
if (_wifiConnRetry < WIFI_MAX_RETRIES) {
|
||||||
|
WiFi.begin();
|
||||||
|
_wifiConnMs = millis();
|
||||||
} else {
|
} else {
|
||||||
Server.end();
|
_wifiConnState = 0;
|
||||||
webserver.stop();
|
_wifiConnMs = millis();
|
||||||
Udp.stop();
|
}
|
||||||
WiFi.mode(WIFI_OFF);
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
if (!_wifiServicesUp) wifiStartServices();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_wifiServicesUp) wifiStopServices();
|
||||||
|
|
||||||
|
if (millis() - _wifiConnMs >= WIFI_RECONNECT_MS) {
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
WiFi.begin();
|
||||||
|
_wifiConnState = 1;
|
||||||
|
_wifiConnMs = millis();
|
||||||
|
_wifiConnRetry = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t crc8_update(uint8_t crc, uint8_t data) {
|
||||||
|
crc ^= data;
|
||||||
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
|
if (crc & 0x80) crc = (crc << 1) ^ 0x07;
|
||||||
|
else crc <<= 1;
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
uint8_t crc8(const uint8_t *data, size_t len) {
|
||||||
|
uint8_t crc = 0x00;
|
||||||
|
while (len--) crc = crc8_update(crc, *data++);
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool execute_pc_command(uint8_t *data, uint8_t *&p, uint8_t *output, uint16_t len, uint32_t* baud_change, size_t output_size) {
|
||||||
|
switch (data[0]) {
|
||||||
|
case 0: { // Set clock
|
||||||
|
if(len < 5) {
|
||||||
|
*p++ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
uint32_t clock = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]);
|
||||||
|
Wire.setClock(clock);
|
||||||
|
} break;
|
||||||
|
case 1: { // Send data
|
||||||
|
if(len < 3) {
|
||||||
|
*p++ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Wire.beginTransmission(data[1]);
|
||||||
|
Wire.write(data + 2, len - 2);
|
||||||
|
auto out = Wire.endTransmission();
|
||||||
|
*p++ = out;
|
||||||
|
} break;
|
||||||
|
case 2: { // Send and receive data
|
||||||
|
if(len < 4) {
|
||||||
|
*p++ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
uint8_t addr = data[1];
|
||||||
|
uint8_t datalen = data[2];
|
||||||
|
|
||||||
|
if(len < 3 + datalen + 1) {
|
||||||
|
*p++ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wire.beginTransmission(addr);
|
||||||
|
Wire.write(data + 3, datalen);
|
||||||
|
auto out = Wire.endTransmission(false);
|
||||||
|
|
||||||
|
uint8_t recvlen = Wire.requestFrom(addr, data[3+datalen]);
|
||||||
|
if ((p - output) + recvlen >= output_size) {
|
||||||
|
*p++ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
*p++ = out;
|
||||||
|
while(Wire.available()) *p++ = Wire.read();
|
||||||
|
} break;
|
||||||
|
case 3: { // Quit
|
||||||
|
i2c_pc_control = false;
|
||||||
|
MuteScreen(false);
|
||||||
|
*baud_change = 115200;
|
||||||
|
} break;
|
||||||
|
case 4: { // Version
|
||||||
|
*p++ = 3;
|
||||||
|
} break;
|
||||||
|
case 5: { // Reboot
|
||||||
|
Serial.write(0);
|
||||||
|
Serial.write(1);
|
||||||
|
Serial.write(5);
|
||||||
|
Serial.flush();
|
||||||
|
esp_restart();
|
||||||
|
} break;
|
||||||
|
case 6: { // Change baud
|
||||||
|
if(len < 5) {
|
||||||
|
*p++ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*baud_change = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) |
|
||||||
|
((uint32_t)data[3] << 8) | ((uint32_t)data[4]);
|
||||||
|
} break;
|
||||||
|
case 7: { // Write to EEPROM
|
||||||
|
if(len < 4) {
|
||||||
|
*p++ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
EEPROM.writeBytes((data[1] << 8) | data[2], data + 3, len - 3);
|
||||||
|
EEPROM.commit();
|
||||||
|
} break;
|
||||||
|
case 8: { // Read from EEPROM
|
||||||
|
if(len < 4) {
|
||||||
|
*p++ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto address = (data[1] << 8) | data[2];
|
||||||
|
*p++ = data[3] + 1;
|
||||||
|
*p++ = 8;
|
||||||
|
for(uint16_t i = 0; i < data[3]; i++) *p++ = EEPROM.read(address + i);
|
||||||
|
} break;
|
||||||
|
case 0xfd: { // Get EEPROM address for userdata
|
||||||
|
*p++ = (uint8_t)(EE_START_CONTROLMODE_DATA >> 8);
|
||||||
|
*p++ = EE_START_CONTROLMODE_DATA & 0xff;
|
||||||
|
*p++ = (uint8_t)(EE_LEN_CONTROLMODE_DATA >> 8);
|
||||||
|
*p++ = EE_LEN_CONTROLMODE_DATA & 0xff;
|
||||||
|
} break;
|
||||||
|
case 0xfe: { // Get EEPROM address for starting control mode on boot
|
||||||
|
*p++ = (uint8_t)(EE_BYTE_CONTROLMODE >> 8);
|
||||||
|
*p++ = EE_BYTE_CONTROLMODE & 0xff;
|
||||||
|
} break;
|
||||||
|
case 0xff:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*p++ = 3;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void total_pc_control() {
|
||||||
|
static uint8_t data[4096];
|
||||||
|
static uint8_t output[4096];
|
||||||
|
uint8_t *p = output + 3;
|
||||||
|
uint32_t baud_change = 0;
|
||||||
|
bool error = false;
|
||||||
|
bool done = false;
|
||||||
|
bool send_crc = false;
|
||||||
|
|
||||||
|
if(Serial.available() > 2 && !done) {
|
||||||
|
uint16_t userlen = (Serial.read() << 8) | Serial.read();
|
||||||
|
if (userlen == 0) {
|
||||||
|
Serial.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(userlen == 0x7e2f) { // ~/
|
||||||
|
error = true;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has_crc = (userlen >> 15) & 1;
|
||||||
|
send_crc = has_crc;
|
||||||
|
uint16_t orig_userlen = userlen;
|
||||||
|
userlen &= 0x7fff;
|
||||||
|
|
||||||
|
if(userlen > 4096) {
|
||||||
|
*p++ = 0;
|
||||||
|
send_crc = false;
|
||||||
|
error = true;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
if(!done) {
|
||||||
|
uint16_t len = Serial.read(data, userlen);
|
||||||
|
if(len != userlen) {
|
||||||
|
error = true;
|
||||||
|
send_crc = false;
|
||||||
|
*p++ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!error & has_crc && Serial.available()) {
|
||||||
|
uint8_t crc = Serial.read();
|
||||||
|
|
||||||
|
uint8_t expected_crc = crc8_update(0, orig_userlen >> 8);
|
||||||
|
expected_crc = crc8_update(expected_crc, orig_userlen & 0xff);
|
||||||
|
for (int i = 0; i < len; i++) expected_crc = crc8_update(expected_crc, data[i]);
|
||||||
|
if(crc != expected_crc) {
|
||||||
|
error = true;
|
||||||
|
send_crc = false;
|
||||||
|
*p++ = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!error) error = execute_pc_command(data, p, output, len, &baud_change, sizeof(output));
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(done) {
|
||||||
|
uint16_t out_len = (p - output) - 2;
|
||||||
|
output[0] = out_len >> 8;
|
||||||
|
output[1] = out_len & 0xff;
|
||||||
|
if(error) output[2] = 0xff;
|
||||||
|
else output[2] = data[0];
|
||||||
|
|
||||||
|
if(send_crc) {
|
||||||
|
output[0] |= 0x80;
|
||||||
|
uint8_t crc = crc8(output, p - output);
|
||||||
|
*p++ = crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.write(output, p - output);
|
||||||
|
|
||||||
|
if(baud_change != 0) {
|
||||||
|
Serial.flush();
|
||||||
|
Serial.updateBaudRate(baud_change);
|
||||||
|
baud_change = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.flush(!error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2422
File diff suppressed because it is too large
Load Diff
+12
-10
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
bool RDSstatus;
|
bool RDSstatus;
|
||||||
bool RDSstatusold;
|
bool RDSstatusold;
|
||||||
TFT_eSPI tft = TFT_eSPI();
|
|
||||||
|
|
||||||
bool Data_Accelerator = false;
|
bool Data_Accelerator = false;
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ bool beepresetstart;
|
|||||||
bool beepresetstop, BWreset, bwtouchtune;
|
bool beepresetstop, BWreset, bwtouchtune;
|
||||||
bool BWtune, change, clockampm;
|
bool BWtune, change, clockampm;
|
||||||
bool direction, dropout;
|
bool direction, dropout;
|
||||||
bool dynamicPTYold, edgebeep, externaltune;
|
bool edgebeep, externaltune;
|
||||||
bool findMemoryAF;
|
bool findMemoryAF;
|
||||||
bool firstTouchHandled = false;
|
bool firstTouchHandled = false;
|
||||||
bool flashing;
|
bool flashing;
|
||||||
@@ -127,7 +126,7 @@ byte scanhold;
|
|||||||
byte scanmodeold;
|
byte scanmodeold;
|
||||||
byte screensaverOptions[5] = {0, 3, 10, 30, 60};
|
byte screensaverOptions[5] = {0, 3, 10, 30, 60};
|
||||||
byte screensaverset;
|
byte screensaverset;
|
||||||
byte showmodulation;
|
byte showaudio;
|
||||||
byte showrdserrors;
|
byte showrdserrors;
|
||||||
byte showSWMIBand;
|
byte showSWMIBand;
|
||||||
byte submenu;
|
byte submenu;
|
||||||
@@ -218,9 +217,7 @@ int8_t MPold = 0;
|
|||||||
int8_t USold = 0;
|
int8_t USold = 0;
|
||||||
int8_t LevelOffset;
|
int8_t LevelOffset;
|
||||||
int8_t LowLevelSet;
|
int8_t LowLevelSet;
|
||||||
int8_t NTPoffset;
|
int8_t Timezone;
|
||||||
int8_t CN;
|
|
||||||
int8_t CNold;
|
|
||||||
RTC_DATA_ATTR int8_t VolSet;
|
RTC_DATA_ATTR int8_t VolSet;
|
||||||
float batteryVold;
|
float batteryVold;
|
||||||
IPAddress remoteip;
|
IPAddress remoteip;
|
||||||
@@ -250,6 +247,7 @@ String XDRGTK_key;
|
|||||||
Detector<String, 1> XDRGTKRDS{""};
|
Detector<String, 1> XDRGTKRDS{""};
|
||||||
uint16_t BW;
|
uint16_t BW;
|
||||||
uint16_t MStatus;
|
uint16_t MStatus;
|
||||||
|
bool modLevelForceRedraw = true;
|
||||||
uint16_t SWMIBandPos;
|
uint16_t SWMIBandPos;
|
||||||
uint16_t SWMIBandPosold;
|
uint16_t SWMIBandPosold;
|
||||||
uint16_t TouchCalData[5];
|
uint16_t TouchCalData[5];
|
||||||
@@ -306,8 +304,8 @@ unsigned long flashingtimer;
|
|||||||
unsigned long keypadtimer;
|
unsigned long keypadtimer;
|
||||||
unsigned long lastTouchTime = 0;
|
unsigned long lastTouchTime = 0;
|
||||||
unsigned long lowsignaltimer;
|
unsigned long lowsignaltimer;
|
||||||
unsigned long ModulationpreviousMillis;
|
unsigned long AudiopreviousMillis;
|
||||||
unsigned long ModulationpeakPreviousMillis;
|
unsigned long AudiopeakPreviousMillis;
|
||||||
unsigned long NTPtimer;
|
unsigned long NTPtimer;
|
||||||
unsigned long peakholdmillis;
|
unsigned long peakholdmillis;
|
||||||
unsigned long processed_rdsblocksold[33];
|
unsigned long processed_rdsblocksold[33];
|
||||||
@@ -322,11 +320,15 @@ unsigned long tuningtimer;
|
|||||||
unsigned long udplogtimer;
|
unsigned long udplogtimer;
|
||||||
unsigned long udptimer;
|
unsigned long udptimer;
|
||||||
bool rds_settings_changed;
|
bool rds_settings_changed;
|
||||||
const size_t language_totalnumber = sizeof(myLanguage) / sizeof(myLanguage[0]);
|
const size_t language_totalnumber = sizeof(Languages) / sizeof(Languages[0]);
|
||||||
const size_t language_entrynumber = sizeof(myLanguage[0]) / sizeof(myLanguage[0][0]);
|
const size_t language_entrynumber = sizeof(Languages[0]) / sizeof(Languages[0][0]);
|
||||||
|
|
||||||
|
volatile bool i2c_pc_control = false;
|
||||||
|
volatile bool i2c_pc_control_init = false;
|
||||||
|
|
||||||
mem presets[EE_PRESETS_CNT];
|
mem presets[EE_PRESETS_CNT];
|
||||||
TEF6686 radio;
|
TEF6686 radio;
|
||||||
|
TFT_eSPI tft = TFT_eSPI();
|
||||||
|
|
||||||
// FrequencySprite.createSprite(200, 50);
|
// FrequencySprite.createSprite(200, 50);
|
||||||
// PSSprite.createSprite(150, 32);
|
// PSSprite.createSprite(150, 32);
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
#include "graphics.h"
|
||||||
|
|
||||||
|
void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, uint8_t fontsize) {
|
||||||
|
uint8_t selectedFont = (language == LANGUAGE_CHS) ? 0 : 2;
|
||||||
|
if (fontsize == 28) selectedFont = (language == LANGUAGE_CHS) ? 4 : 3;
|
||||||
|
else if (fontsize == 48) selectedFont = 1;
|
||||||
|
|
||||||
|
tft.setTextColor(color, smoothcolor);
|
||||||
|
|
||||||
|
switch (offset) {
|
||||||
|
case -1: tft.setTextDatum(TL_DATUM); break;
|
||||||
|
case 0: tft.setTextDatum(TC_DATUM); break;
|
||||||
|
case 1: tft.setTextDatum(TR_DATUM); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String modifiedText = text;
|
||||||
|
modifiedText.replace("\n", " ");
|
||||||
|
|
||||||
|
tft.drawString(modifiedText, x, y, selectedFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tftPrint16(int8_t offset, const String & text, int16_t x, int16_t y, int color, int smoothcolor, bool force_font, bool font) {
|
||||||
|
uint8_t selectedFont = (language == LANGUAGE_CHS) ? 0 : 2;
|
||||||
|
if(force_font) selectedFont = 0 ? font : 2;
|
||||||
|
|
||||||
|
tft.setTextColor(color, smoothcolor);
|
||||||
|
|
||||||
|
switch (offset) {
|
||||||
|
case -1: tft.setTextDatum(TL_DATUM); break;
|
||||||
|
case 0: tft.setTextDatum(TC_DATUM); break;
|
||||||
|
case 1: tft.setTextDatum(TR_DATUM); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String modifiedText = text;
|
||||||
|
modifiedText.replace("\n", " ");
|
||||||
|
|
||||||
|
tft.drawString(modifiedText, x, y, selectedFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tftReplace(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, uint8_t fontsize) {
|
||||||
|
uint8_t selectedFont = 0 ? (language == LANGUAGE_CHS) : 2;
|
||||||
|
if(fontsize == 28) selectedFont = (language == LANGUAGE_CHS) ? 4 : 3;
|
||||||
|
else if(fontsize == 48) selectedFont = 1;
|
||||||
|
|
||||||
|
switch (offset) {
|
||||||
|
case -1: tft.setTextDatum(TL_DATUM); break;
|
||||||
|
case 0: tft.setTextDatum(TC_DATUM); break;
|
||||||
|
case 1: tft.setTextDatum(TR_DATUM); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.setTextColor(background, background, false);
|
||||||
|
tft.drawString(textold, x, y, selectedFont);
|
||||||
|
|
||||||
|
String modifiedText = text;
|
||||||
|
modifiedText.replace("\n", " ");
|
||||||
|
|
||||||
|
tft.setTextColor(color, smoothcolor, false);
|
||||||
|
tft.drawString(modifiedText, x, y, selectedFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tftReplace16(int8_t offset, const String & textold, const String & text, int16_t x, int16_t y, int color, int smoothcolor, int background, bool force_font, bool font) {
|
||||||
|
uint8_t selectedFont = (language == LANGUAGE_CHS) ? 0 : 2;
|
||||||
|
if(force_font) selectedFont = 0 ? font : 2;
|
||||||
|
|
||||||
|
switch (offset) {
|
||||||
|
case -1: tft.setTextDatum(TL_DATUM); break;
|
||||||
|
case 0: tft.setTextDatum(TC_DATUM); break;
|
||||||
|
case 1: tft.setTextDatum(TR_DATUM); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.setTextColor(background, background, false);
|
||||||
|
tft.drawString(textold, x, y, selectedFont);
|
||||||
|
|
||||||
|
String modifiedText = text;
|
||||||
|
modifiedText.replace("\n", " ");
|
||||||
|
|
||||||
|
tft.setTextColor(color, smoothcolor, false);
|
||||||
|
tft.drawString(modifiedText, x, y, selectedFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateFonts() {
|
||||||
|
// This is at setup:
|
||||||
|
// tft.loadFont(FONT48, 1);
|
||||||
|
|
||||||
|
// tft.loadFont(FONT16_CHS, 0);
|
||||||
|
// tft.loadFont(FONT16, 2);
|
||||||
|
// tft.loadFont(FONT28, 3);
|
||||||
|
// tft.loadFont(FONT28_CHS, 4);
|
||||||
|
|
||||||
|
if (language == LANGUAGE_CHS) {
|
||||||
|
if (menu) PSSprite.setTextFont(1); else PSSprite.setTextFont(3);
|
||||||
|
OneBigLineSprite.copyFontFromTFT(4, 0);
|
||||||
|
FullLineSprite.copyFontFromTFT(0, 0);
|
||||||
|
GeneralTextSprite.copyFontFromTFT(0, 0);
|
||||||
|
GeneralTextSprite.copyFontFromTFT(4, 1);
|
||||||
|
FrequencySprite.copyFontFromTFT(0, 6);
|
||||||
|
SquelchSprite.copyFontFromTFT(0, 0);
|
||||||
|
} else {
|
||||||
|
if (menu) PSSprite.setTextFont(0); else PSSprite.setTextFont(2);
|
||||||
|
OneBigLineSprite.copyFontFromTFT(3, 0);
|
||||||
|
FullLineSprite.copyFontFromTFT(2, 0);
|
||||||
|
GeneralTextSprite.copyFontFromTFT(2, 0);
|
||||||
|
GeneralTextSprite.copyFontFromTFT(3, 1);
|
||||||
|
FrequencySprite.copyFontFromTFT(2, 6);
|
||||||
|
SquelchSprite.copyFontFromTFT(2, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
+431
-573
File diff suppressed because it is too large
Load Diff
+10
-13
@@ -41,9 +41,9 @@ void handleRoot() {
|
|||||||
html += "<img src=\"/logo.png\" alt=\"FMDX website\">";
|
html += "<img src=\"/logo.png\" alt=\"FMDX website\">";
|
||||||
html += "</a>";
|
html += "</a>";
|
||||||
|
|
||||||
html += "<h1>" + String(textUI(283)) + "</h1>";
|
html += "<h1>" + String(textUI(282)) + "</h1>";
|
||||||
html += "<button onclick=\"window.location.href='/downloadCSV'\">" + String(textUI(284)) + "</button>";
|
html += "<button onclick=\"window.location.href='/downloadCSV'\">" + String(textUI(283)) + "</button>";
|
||||||
html += "<button class=\"go-to-bottom\" onclick=\" window.scrollTo(0, document.body.scrollHeight);\">" + String(textUI(286)) + "</button>";
|
html += "<button class=\"go-to-bottom\" onclick=\" window.scrollTo(0, document.body.scrollHeight);\">" + String(textUI(285)) + "</button>";
|
||||||
|
|
||||||
// Sorting function with icons
|
// Sorting function with icons
|
||||||
html += "<script>";
|
html += "<script>";
|
||||||
@@ -104,7 +104,7 @@ void handleRoot() {
|
|||||||
String column = header.substring(startIndex, endIndex);
|
String column = header.substring(startIndex, endIndex);
|
||||||
|
|
||||||
if (column.equalsIgnoreCase("PI")) piCodeIndex = columnIndex;
|
if (column.equalsIgnoreCase("PI")) piCodeIndex = columnIndex;
|
||||||
if (column.equalsIgnoreCase("Frequency")) frequencyIndex = columnIndex;
|
else if (column.equalsIgnoreCase("Frequency")) frequencyIndex = columnIndex;
|
||||||
|
|
||||||
startIndex = endIndex + 1;
|
startIndex = endIndex + 1;
|
||||||
columnIndex++;
|
columnIndex++;
|
||||||
@@ -143,9 +143,9 @@ void handleRoot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
} else html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(296)) + "</td></tr>";
|
} else html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(295)) + "</td></tr>";
|
||||||
|
|
||||||
if (!hasData) html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(285)) + "</td></tr>";
|
if (!hasData) html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(284)) + "</td></tr>";
|
||||||
|
|
||||||
html += "</table>";
|
html += "</table>";
|
||||||
html += "</body></html>";
|
html += "</body></html>";
|
||||||
@@ -170,9 +170,7 @@ void handleDownloadCSV() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool handleCreateNewLogbook() {
|
bool handleCreateNewLogbook() {
|
||||||
if (SPIFFS.exists("/logbook.csv")) {
|
if (SPIFFS.exists("/logbook.csv") && !SPIFFS.remove("/logbook.csv")) return false;
|
||||||
if (!SPIFFS.remove("/logbook.csv")) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs::File file = SPIFFS.open("/logbook.csv", "w");
|
fs::File file = SPIFFS.open("/logbook.csv", "w");
|
||||||
if (!file) return false;
|
if (!file) return false;
|
||||||
@@ -257,14 +255,14 @@ String getCurrentDateTime(bool inUTC) {
|
|||||||
int utcOffsetHours = 0;
|
int utcOffsetHours = 0;
|
||||||
|
|
||||||
if (!inUTC) {
|
if (!inUTC) {
|
||||||
currentEpoch += (NTPupdated ? NTPoffset * 3600 : radio.rds.offset); // Apply GMT offset if NTPupdated, else RDS offset
|
currentEpoch += (NTPupdated ? Timezone * 3600 : radio.rds.offset); // Apply GMT offset if NTPupdated, else RDS offset
|
||||||
|
|
||||||
if (NTPupdated && autoDST) {
|
if (NTPupdated && autoDST) {
|
||||||
struct tm tempTimeInfo;
|
struct tm tempTimeInfo;
|
||||||
localtime_r(¤tEpoch, &tempTimeInfo);
|
localtime_r(¤tEpoch, &tempTimeInfo);
|
||||||
if (isDST(mktime(&tempTimeInfo))) currentEpoch += 3600;
|
if (isDST(mktime(&tempTimeInfo))) currentEpoch += 3600;
|
||||||
}
|
}
|
||||||
} else utcOffsetHours = (NTPupdated ? NTPoffset : radio.rds.offset / 3600);
|
} else utcOffsetHours = (NTPupdated ? Timezone : radio.rds.offset / 3600);
|
||||||
|
|
||||||
localtime_r(¤tEpoch, &timeInfo);
|
localtime_r(¤tEpoch, &timeInfo);
|
||||||
|
|
||||||
@@ -343,8 +341,7 @@ void printLogbookCSV() {
|
|||||||
Serial.println("===== Start of logbook.csv =====");
|
Serial.println("===== Start of logbook.csv =====");
|
||||||
|
|
||||||
while (file.available()) {
|
while (file.available()) {
|
||||||
String line = file.readStringUntil('\n');
|
Serial.println(file.readStringUntil('\n'));
|
||||||
Serial.println(line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|||||||
+755
-3317
File diff suppressed because it is too large
Load Diff
+14
-9
@@ -1,4 +1,6 @@
|
|||||||
#include "nonvolatile.h"
|
#include "nonvolatile.h"
|
||||||
|
#include "globals.h"
|
||||||
|
#include "logbook.h"
|
||||||
|
|
||||||
void StoreFrequency() {
|
void StoreFrequency() {
|
||||||
switch (band) {
|
switch (band) {
|
||||||
@@ -67,7 +69,7 @@ void saveData() {
|
|||||||
EEPROM.writeByte(EE_BYTE_RDS_FILTER, radio.rds.filter);
|
EEPROM.writeByte(EE_BYTE_RDS_FILTER, radio.rds.filter);
|
||||||
EEPROM.writeByte(EE_BYTE_RDS_PIERRORS, radio.rds.pierrors);
|
EEPROM.writeByte(EE_BYTE_RDS_PIERRORS, radio.rds.pierrors);
|
||||||
EEPROM.writeByte(EE_BYTE_USESQUELCH, usesquelch);
|
EEPROM.writeByte(EE_BYTE_USESQUELCH, usesquelch);
|
||||||
EEPROM.writeByte(EE_BYTE_SHOWMODULATION, showmodulation);
|
EEPROM.writeByte(EE_BYTE_SHOWAUDIO, showaudio);
|
||||||
EEPROM.writeByte(EE_BYTE_AM_NB, amnb);
|
EEPROM.writeByte(EE_BYTE_AM_NB, amnb);
|
||||||
EEPROM.writeByte(EE_BYTE_FM_NB, fmnb);
|
EEPROM.writeByte(EE_BYTE_FM_NB, fmnb);
|
||||||
EEPROM.writeByte(EE_BYTE_AUDIOMODE, audiomode);
|
EEPROM.writeByte(EE_BYTE_AUDIOMODE, audiomode);
|
||||||
@@ -118,11 +120,12 @@ void saveData() {
|
|||||||
EEPROM.writeByte(EE_BYTE_MEMPIONLY, mempionly);
|
EEPROM.writeByte(EE_BYTE_MEMPIONLY, mempionly);
|
||||||
EEPROM.writeByte(EE_BYTE_MEMDOUBLEPI, memdoublepi);
|
EEPROM.writeByte(EE_BYTE_MEMDOUBLEPI, memdoublepi);
|
||||||
EEPROM.writeByte(EE_BYTE_WAITONLYONSIGNAL, scanholdonsignal);
|
EEPROM.writeByte(EE_BYTE_WAITONLYONSIGNAL, scanholdonsignal);
|
||||||
EEPROM.writeByte(EE_BYTE_NTPOFFSET, NTPoffset);
|
EEPROM.writeByte(EE_BYTE_TIMEZONE, Timezone);
|
||||||
EEPROM.writeByte(EE_BYTE_AUTOLOG, autolog);
|
EEPROM.writeByte(EE_BYTE_AUTOLOG, autolog);
|
||||||
EEPROM.writeByte(EE_BYTE_AUTODST, autoDST);
|
EEPROM.writeByte(EE_BYTE_AUTODST, autoDST);
|
||||||
EEPROM.writeByte(EE_BYTE_CLOCKAMPM, clockampm);
|
EEPROM.writeByte(EE_BYTE_CLOCKAMPM, clockampm);
|
||||||
EEPROM.writeUInt(EE_UINT16_PICTLOCK, radio.rds.PICTlock);
|
EEPROM.writeUInt(EE_UINT16_PICTLOCK, radio.rds.PICTlock);
|
||||||
|
EEPROM.writeByte(EE_BYTE_CONTROLMODE, 0); // Always 0
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +175,7 @@ void loadData() {
|
|||||||
frequency_SW = EEPROM.readUInt(EE_UINT16_FREQUENCY_SW);
|
frequency_SW = EEPROM.readUInt(EE_UINT16_FREQUENCY_SW);
|
||||||
XDRGTK_key = EEPROM.readString(EE_STRING_XDRGTK_KEY);
|
XDRGTK_key = EEPROM.readString(EE_STRING_XDRGTK_KEY);
|
||||||
usesquelch = EEPROM.readByte(EE_BYTE_USESQUELCH);
|
usesquelch = EEPROM.readByte(EE_BYTE_USESQUELCH);
|
||||||
showmodulation = EEPROM.readByte(EE_BYTE_SHOWMODULATION);
|
showaudio = EEPROM.readByte(EE_BYTE_SHOWAUDIO);
|
||||||
amnb = EEPROM.readByte(EE_BYTE_AM_NB);
|
amnb = EEPROM.readByte(EE_BYTE_AM_NB);
|
||||||
fmnb = EEPROM.readByte(EE_BYTE_FM_NB);
|
fmnb = EEPROM.readByte(EE_BYTE_FM_NB);
|
||||||
audiomode = EEPROM.readByte(EE_BYTE_AUDIOMODE);
|
audiomode = EEPROM.readByte(EE_BYTE_AUDIOMODE);
|
||||||
@@ -231,12 +234,13 @@ void loadData() {
|
|||||||
TouchCalData[3] = EEPROM.readUInt(EE_UINT16_CALTOUCH4);
|
TouchCalData[3] = EEPROM.readUInt(EE_UINT16_CALTOUCH4);
|
||||||
TouchCalData[4] = EEPROM.readUInt(EE_UINT16_CALTOUCH5);
|
TouchCalData[4] = EEPROM.readUInt(EE_UINT16_CALTOUCH5);
|
||||||
invertdisplay = EEPROM.readByte(EE_BYTE_INVERTDISPLAY);
|
invertdisplay = EEPROM.readByte(EE_BYTE_INVERTDISPLAY);
|
||||||
NTPoffset = EEPROM.readByte(EE_BYTE_NTPOFFSET);
|
Timezone = EEPROM.readByte(EE_BYTE_TIMEZONE);
|
||||||
autolog = EEPROM.readByte(EE_BYTE_AUTOLOG);
|
autolog = EEPROM.readByte(EE_BYTE_AUTOLOG);
|
||||||
autoDST = EEPROM.readByte(EE_BYTE_AUTODST);
|
autoDST = EEPROM.readByte(EE_BYTE_AUTODST);
|
||||||
clockampm = EEPROM.readByte(EE_BYTE_CLOCKAMPM);
|
clockampm = EEPROM.readByte(EE_BYTE_CLOCKAMPM);
|
||||||
logcounter = EEPROM.readUInt(EE_UINT16_LOGCOUNTER);
|
logcounter = EEPROM.readUInt(EE_UINT16_LOGCOUNTER);
|
||||||
radio.rds.PICTlock = EEPROM.readUInt(EE_UINT16_PICTLOCK);
|
radio.rds.PICTlock = EEPROM.readUInt(EE_UINT16_PICTLOCK);
|
||||||
|
i2c_pc_control = i2c_pc_control_init = EEPROM.readByte(EE_BYTE_CONTROLMODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultSettings() {
|
void DefaultSettings() {
|
||||||
@@ -247,7 +251,7 @@ void DefaultSettings() {
|
|||||||
EEPROM.writeUInt(EE_UINT16_CONVERTERSET, 0);
|
EEPROM.writeUInt(EE_UINT16_CONVERTERSET, 0);
|
||||||
EEPROM.writeUInt(EE_UINT16_FMLOWEDGESET, 875);
|
EEPROM.writeUInt(EE_UINT16_FMLOWEDGESET, 875);
|
||||||
EEPROM.writeUInt(EE_UINT16_FMHIGHEDGESET, 1080);
|
EEPROM.writeUInt(EE_UINT16_FMHIGHEDGESET, 1080);
|
||||||
EEPROM.writeByte(EE_BYTE_CONTRASTSET, 20);
|
EEPROM.writeByte(EE_BYTE_CONTRASTSET, 10);
|
||||||
EEPROM.writeByte(EE_BYTE_STEREOLEVEL, 0);
|
EEPROM.writeByte(EE_BYTE_STEREOLEVEL, 0);
|
||||||
EEPROM.writeByte(EE_BYTE_BANDFM, FM_BAND_ALL);
|
EEPROM.writeByte(EE_BYTE_BANDFM, FM_BAND_ALL);
|
||||||
EEPROM.writeByte(EE_BYTE_BANDAM, AM_BAND_ALL);
|
EEPROM.writeByte(EE_BYTE_BANDAM, AM_BAND_ALL);
|
||||||
@@ -257,7 +261,7 @@ void DefaultSettings() {
|
|||||||
EEPROM.writeByte(EE_BYTE_RTBUFFER, 0);
|
EEPROM.writeByte(EE_BYTE_RTBUFFER, 0);
|
||||||
EEPROM.writeByte(EE_BYTE_EDGEBEEP, 0);
|
EEPROM.writeByte(EE_BYTE_EDGEBEEP, 0);
|
||||||
EEPROM.writeByte(EE_BYTE_SOFTMUTEAM, 1);
|
EEPROM.writeByte(EE_BYTE_SOFTMUTEAM, 1);
|
||||||
EEPROM.writeByte(EE_BYTE_SOFTMUTEFM, 0);
|
EEPROM.writeByte(EE_BYTE_SOFTMUTEFM, 1);
|
||||||
EEPROM.writeUInt(EE_UINT16_FREQUENCY_AM, 828);
|
EEPROM.writeUInt(EE_UINT16_FREQUENCY_AM, 828);
|
||||||
EEPROM.writeByte(EE_BYTE_LANGUAGE, 0);
|
EEPROM.writeByte(EE_BYTE_LANGUAGE, 0);
|
||||||
EEPROM.writeByte(EE_BYTE_SHOWRDSERRORS, 0);
|
EEPROM.writeByte(EE_BYTE_SHOWRDSERRORS, 0);
|
||||||
@@ -282,7 +286,7 @@ void DefaultSettings() {
|
|||||||
EEPROM.writeUInt(EE_UINT16_FREQUENCY_SW, 1800);
|
EEPROM.writeUInt(EE_UINT16_FREQUENCY_SW, 1800);
|
||||||
EEPROM.writeString(EE_STRING_XDRGTK_KEY, "password");
|
EEPROM.writeString(EE_STRING_XDRGTK_KEY, "password");
|
||||||
EEPROM.writeByte(EE_BYTE_USESQUELCH, 1);
|
EEPROM.writeByte(EE_BYTE_USESQUELCH, 1);
|
||||||
EEPROM.writeByte(EE_BYTE_SHOWMODULATION, 1);
|
EEPROM.writeByte(EE_BYTE_SHOWAUDIO, 1);
|
||||||
EEPROM.writeByte(EE_BYTE_AM_NB, 0);
|
EEPROM.writeByte(EE_BYTE_AM_NB, 0);
|
||||||
EEPROM.writeByte(EE_BYTE_FM_NB, 0);
|
EEPROM.writeByte(EE_BYTE_FM_NB, 0);
|
||||||
EEPROM.writeByte(EE_BYTE_AUDIOMODE, 0);
|
EEPROM.writeByte(EE_BYTE_AUDIOMODE, 0);
|
||||||
@@ -338,13 +342,14 @@ void DefaultSettings() {
|
|||||||
EEPROM.writeUInt(EE_UINT16_CALTOUCH3, 300);
|
EEPROM.writeUInt(EE_UINT16_CALTOUCH3, 300);
|
||||||
EEPROM.writeUInt(EE_UINT16_CALTOUCH4, 3450);
|
EEPROM.writeUInt(EE_UINT16_CALTOUCH4, 3450);
|
||||||
EEPROM.writeUInt(EE_UINT16_CALTOUCH5, 3);
|
EEPROM.writeUInt(EE_UINT16_CALTOUCH5, 3);
|
||||||
EEPROM.writeByte(EE_BYTE_NTPOFFSET, 1);
|
EEPROM.writeByte(EE_BYTE_TIMEZONE, 0);
|
||||||
EEPROM.writeByte(EE_BYTE_AUTOLOG, 1);
|
EEPROM.writeByte(EE_BYTE_AUTOLOG, 1);
|
||||||
EEPROM.writeByte(EE_BYTE_AUTODST, 1);
|
EEPROM.writeByte(EE_BYTE_AUTODST, 1);
|
||||||
EEPROM.writeByte(EE_BYTE_CLOCKAMPM, 0);
|
EEPROM.writeByte(EE_BYTE_CLOCKAMPM, 0);
|
||||||
EEPROM.writeUInt(EE_UINT16_PICTLOCK, 0);
|
EEPROM.writeUInt(EE_UINT16_PICTLOCK, 0);
|
||||||
|
EEPROM.writeByte(EE_BYTE_CONTROLMODE, 0);
|
||||||
|
|
||||||
EEPROM.writeByte(EE_BYTE_SPISPEED, 7);
|
EEPROM.writeByte(EE_BYTE_SPISPEED, 0);
|
||||||
|
|
||||||
#ifdef DEEPELEC_DP_66X
|
#ifdef DEEPELEC_DP_66X
|
||||||
EEPROM.writeByte(EE_BYTE_ROTARYMODE, 1);
|
EEPROM.writeByte(EE_BYTE_ROTARYMODE, 1);
|
||||||
|
|||||||
+77
-83
@@ -1,6 +1,7 @@
|
|||||||
#include "rds.h"
|
#include "rds.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "graphics.h"
|
||||||
|
|
||||||
String HexStringold;
|
String HexStringold;
|
||||||
float smoothBER = 0;
|
float smoothBER = 0;
|
||||||
@@ -17,9 +18,8 @@ void ShowAdvancedRDS() {
|
|||||||
if (radio.rds.rdsDerror) tft.fillCircle(200, 41, 5, SignificantColor); else tft.fillCircle(200, 41, 5, InsignificantColor);
|
if (radio.rds.rdsDerror) tft.fillCircle(200, 41, 5, SignificantColor); else tft.fillCircle(200, 41, 5, InsignificantColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radio.rds.hasDynamicPTY != dynamicPTYold) {
|
if(radio.rds.hasDynamicPTY.changed(0)) {
|
||||||
if (radio.rds.hasDynamicPTY) tft.fillCircle(310, 137, 5, InsignificantColor); else tft.fillCircle(310, 137, 5, SignificantColor);
|
if(radio.rds.hasDynamicPTY.get()) tft.fillCircle(310, 137, 5, InsignificantColor); else tft.fillCircle(310, 137, 5, SignificantColor);
|
||||||
dynamicPTYold = radio.rds.hasDynamicPTY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(radio.rds.hasArtificialhead.changed(0)) {
|
if(radio.rds.hasArtificialhead.changed(0)) {
|
||||||
@@ -37,17 +37,17 @@ void ShowAdvancedRDS() {
|
|||||||
if (radio.rds.PTYN.changed(0) || rdsreset) {
|
if (radio.rds.PTYN.changed(0) || rdsreset) {
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (radio.rds.PTYN.getPrev() != "PTYN N/A" || radio.rds.hasPTYN) {
|
if (radio.rds.PTYN.getPrev() != "PTYN N/A" || radio.rds.hasPTYN) {
|
||||||
tftPrint(ALEFT, "PTYN N/A", 216, 109, BackgroundColor, BackgroundColor, 16);
|
tftPrint16(ALEFT, "PTYN N/A", 216, 109, BackgroundColor, BackgroundColor);
|
||||||
tftPrint(ALEFT, radio.rds.PTYN.getPrev(), 216, 109, BackgroundColor, BackgroundColor, 16);
|
tftPrint16(ALEFT, radio.rds.PTYN.getPrev(), 216, 109, BackgroundColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
if (!radio.rds.hasPTYN) radio.rds.PTYN = "PTYN N/A";
|
if (!radio.rds.hasPTYN) radio.rds.PTYN = "PTYN N/A";
|
||||||
tftPrint(ALEFT, String(radio.rds.PTYN), 216, 109, RDSColor, RDSColorSmooth, 16);
|
tftPrint16(ALEFT, String(radio.rds.PTYN), 216, 109, RDSColor, RDSColorSmooth); // PTYN is UCS-2, meaning no chinese characters. 美国人!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasafold != radio.rds.hasAF) {
|
if (hasafold != radio.rds.hasAF) {
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (radio.rds.hasAF) tftPrint(ALEFT, "AF", 50, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "AF", 50, 51, GreyoutColor, BackgroundColor, 16);
|
if (radio.rds.hasAF) tftPrint16(ALEFT, "AF", 50, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "AF", 50, 51, GreyoutColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
hasafold = radio.rds.hasAF;
|
hasafold = radio.rds.hasAF;
|
||||||
}
|
}
|
||||||
@@ -65,39 +65,45 @@ void ShowAdvancedRDS() {
|
|||||||
Udp.endPacket();
|
Udp.endPacket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!screenmute) eccDisplay.update(ECCString, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
|
if(!screenmute) {
|
||||||
|
uint8_t font = 0;
|
||||||
|
if(radio.rds.ECC.get() == 190) font = 1; // Chiba (Chiba)
|
||||||
|
else if(radio.rds.ECC.get() == 192) font = 1;
|
||||||
|
else if(radio.rds.ECC.get() == 201) font = 1;
|
||||||
|
eccDisplay.update(ECCString, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, font);
|
||||||
|
}
|
||||||
|
|
||||||
String eonstring;
|
String eonstring;
|
||||||
if (radio.eon_counter > 0) for (byte i = 0; i < radio.eon_counter; i++) eonstring += String(radio.eon[i].picode) + (radio.eon[i].ps.length() > 0 ? String(": " + String(radio.eon[i].ps)) : "") + (radio.eon[i].mappedfreq > 0 ? String(" " + String(radio.eon[i].mappedfreq / 100) + "." + String((radio.eon[i].mappedfreq % 100) / 10)) : "") + (radio.eon[i].mappedfreq2 > 0 ? String(" / " + String(radio.eon[i].mappedfreq2 / 100) + "." + String((radio.eon[i].mappedfreq2 % 100) / 10)) : "") + (radio.eon[i].mappedfreq3 > 0 ? String(" / " + String(radio.eon[i].mappedfreq3 / 100) + "." + String((radio.eon[i].mappedfreq3 % 100) / 10)) : "") + (i == radio.eon_counter - 1 ? "" : " | "); else eonstring = textUI(85);
|
if (radio.eon_counter > 0) for (byte i = 0; i < radio.eon_counter; i++) eonstring += String(radio.eon[i].picode) + (radio.eon[i].ps.length() > 0 ? String(": " + String(radio.eon[i].ps)) : "") + (radio.eon[i].mappedfreq > 0 ? String(" " + String(radio.eon[i].mappedfreq / 100) + "." + String((radio.eon[i].mappedfreq % 100) / 10)) : "") + (radio.eon[i].mappedfreq2 > 0 ? String(" / " + String(radio.eon[i].mappedfreq2 / 100) + "." + String((radio.eon[i].mappedfreq2 % 100) / 10)) : "") + (radio.eon[i].mappedfreq3 > 0 ? String(" / " + String(radio.eon[i].mappedfreq3 / 100) + "." + String((radio.eon[i].mappedfreq3 % 100) / 10)) : "") + (i == radio.eon_counter - 1 ? "" : " | "); else eonstring = textUI(85);
|
||||||
if (radio.rds.hasEON.changed(0)) {
|
if (radio.rds.hasEON.changed(0)) {
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (radio.eon_counter > 0) tftPrint(ALEFT, "EON", 153, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "EON", 153, 51, GreyoutColor, BackgroundColor, 16);
|
if (radio.eon_counter > 0) tftPrint16(ALEFT, "EON", 153, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "EON", 153, 51, GreyoutColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!screenmute) eonDisplay.update(eonstring, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
|
if(!screenmute) eonDisplay.update(eonstring, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
|
||||||
|
|
||||||
String rtplusstring;
|
String rtplusstring;
|
||||||
if (radio.rds.hasRTplus) rtplusstring = (radio.rds.rdsplusTag1 != 169 ? String(textUI(radio.rds.rdsplusTag1)) + ": " + String(radio.rds.RTContent1) : "") + (radio.rds.rdsplusTag2 != 169 ? " - " + String(textUI(radio.rds.rdsplusTag2)) + ": " + String(radio.rds.RTContent2) : ""); else rtplusstring = textUI(86);
|
if (radio.rds.hasRTplus) rtplusstring = (radio.rds.rdsplusTag1 != 166 ? String(textUI(radio.rds.rdsplusTag1)) + ": " + String(radio.rds.RTContent1) : "") + (radio.rds.rdsplusTag2 != 169 ? " - " + String(textUI(radio.rds.rdsplusTag2)) + ": " + String(radio.rds.RTContent2) : ""); else rtplusstring = textUI(86);
|
||||||
if (radio.rds.hasRTplus.changed(0)) {
|
if (radio.rds.hasRTplus.changed(0)) {
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (radio.rds.hasRTplus) tftPrint(ALEFT, "RT+", 123, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "RT+", 123, 51, GreyoutColor, BackgroundColor, 16);
|
if (radio.rds.hasRTplus) tftPrint16(ALEFT, "RT+", 123, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "RT+", 123, 51, GreyoutColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!screenmute) rtplusDisplay.update(rtplusstring, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
|
if(!screenmute) rtplusDisplay.update(rtplusstring, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
|
||||||
|
|
||||||
if (radio.rds.TP.changed(0) && !screenmute) {
|
if (radio.rds.TP.changed(0) && !screenmute) {
|
||||||
if (radio.rds.TP) tftPrint(ALEFT, "TP", 2, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "TP", 2, 51, GreyoutColor, BackgroundColor, 16);
|
if (radio.rds.TP) tftPrint16(ALEFT, "TP", 2, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "TP", 2, 51, GreyoutColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radio.rds.TA.changed(0) && !screenmute) {
|
if (radio.rds.TA.changed(0) && !screenmute) {
|
||||||
if (radio.rds.TA) tftPrint(ALEFT, "TA", 24, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "TA", 24, 51, GreyoutColor, BackgroundColor, 16);
|
if (radio.rds.TA) tftPrint16(ALEFT, "TA", 24, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "TA", 24, 51, GreyoutColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (afmethodBold != radio.afmethodB || rdsreset) {
|
if (afmethodBold != radio.afmethodB || rdsreset) {
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (radio.afmethodB) tftPrint(ALEFT, "-B", 68, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "-B", 68, 51, GreyoutColor, BackgroundColor, 16);
|
if (radio.afmethodB) tftPrint16(ALEFT, "-B", 68, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "-B", 68, 51, GreyoutColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
afmethodBold = radio.afmethodB;
|
afmethodBold = radio.afmethodB;
|
||||||
}
|
}
|
||||||
@@ -110,7 +116,7 @@ void ShowAdvancedRDS() {
|
|||||||
|
|
||||||
if (radio.rds.hasTMC.changed(0)) {
|
if (radio.rds.hasTMC.changed(0)) {
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (radio.rds.hasTMC) tftPrint(ALEFT, "TMC", 88, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "TMC", 88, 51, GreyoutColor, BackgroundColor, 16);
|
if (radio.rds.hasTMC) tftPrint16(ALEFT, "TMC", 88, 51, RDSColor, RDSColorSmooth); else tftPrint16(ALEFT, "TMC", 88, 51, GreyoutColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +127,7 @@ void doAF() {
|
|||||||
if (radio.af_counter != af_counterold && radio.rds.hasAF) {
|
if (radio.af_counter != af_counterold && radio.rds.hasAF) {
|
||||||
if (wifi) {
|
if (wifi) {
|
||||||
Udp.beginPacket(remoteip, 9030);
|
Udp.beginPacket(remoteip, 9030);
|
||||||
Udp.print("from=TEF_tuner_" + String(stationlistid, DEC) + ";AF=");
|
Udp.print("from=TEF_tuner_" + String(stationlistid) + ";AF=");
|
||||||
|
|
||||||
for (byte af_scan = 0; af_scan < radio.af_counter; af_scan++) {
|
for (byte af_scan = 0; af_scan < radio.af_counter; af_scan++) {
|
||||||
if (wifi) {
|
if (wifi) {
|
||||||
@@ -182,7 +188,7 @@ void readRds() {
|
|||||||
if (!rdsstatscreen) {
|
if (!rdsstatscreen) {
|
||||||
if (radio.rds.region == 0) tftPrint(ACENTER, PIold, 275, advancedRDS ? 75 : 187, RDSColor, RDSColorSmooth, 28);
|
if (radio.rds.region == 0) tftPrint(ACENTER, PIold, 275, advancedRDS ? 75 : 187, RDSColor, RDSColorSmooth, 28);
|
||||||
else {
|
else {
|
||||||
tftPrint(ALEFT, PIold, 240, advancedRDS ? 72 : 184, RDSColor, RDSColorSmooth, 16);
|
tftPrint16(ALEFT, PIold, 240, advancedRDS ? 72 : 184, RDSColor, RDSColorSmooth);
|
||||||
tftPrint(ALEFT, stationIDold, 240, advancedRDS ? 89 : 201, RDSColor, RDSColorSmooth, 16);
|
tftPrint(ALEFT, stationIDold, 240, advancedRDS ? 89 : 201, RDSColor, RDSColorSmooth, 16);
|
||||||
tftPrint( 1, stationStateold, 318, advancedRDS ? 89 : 201, advancedRDS ? RDSColor : RDSDropoutColor, advancedRDS ? RDSColorSmooth : RDSDropoutColorSmooth, 16);
|
tftPrint( 1, stationStateold, 318, advancedRDS ? 89 : 201, advancedRDS ? RDSColor : RDSDropoutColor, advancedRDS ? RDSColorSmooth : RDSDropoutColorSmooth, 16);
|
||||||
}
|
}
|
||||||
@@ -198,8 +204,7 @@ void readRds() {
|
|||||||
} else {
|
} else {
|
||||||
PSSprite.setTextColor(RDSColor, RDSColorSmooth, false);
|
PSSprite.setTextColor(RDSColor, RDSColorSmooth, false);
|
||||||
PSSprite.drawString(PSold, 0, 2);
|
PSSprite.drawString(PSold, 0, 2);
|
||||||
}
|
} PSSprite.pushSprite(36, advancedRDS ? 72 : 185);
|
||||||
PSSprite.pushSprite(36, advancedRDS ? 72 : 185);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tft.fillCircle(314, 223, 2, GreyoutColor);
|
tft.fillCircle(314, 223, 2, GreyoutColor);
|
||||||
@@ -243,13 +248,13 @@ void readRds() {
|
|||||||
sprintf(hexbuf, "%04X", radio.rds.rdsD); XDRGTKRDS += hexbuf;
|
sprintf(hexbuf, "%04X", radio.rds.rdsD); XDRGTKRDS += hexbuf;
|
||||||
|
|
||||||
uint8_t erroutput = 0;
|
uint8_t erroutput = 0;
|
||||||
erroutput |= ((radio.rds.rdsErr >> 8) & B00110000) >> 4;
|
erroutput |= ((radio.rds.rdsErr >> 8) & 0x30) >> 4;
|
||||||
erroutput |= ((radio.rds.rdsErr >> 8) & B00001100);
|
erroutput |= ((radio.rds.rdsErr >> 8) & 0xC);
|
||||||
erroutput |= ((radio.rds.rdsErr >> 8) & B00000011) << 4;
|
erroutput |= ((radio.rds.rdsErr >> 8) & 3) << 4;
|
||||||
|
|
||||||
sprintf(hexbuf, "%X%X", (erroutput >> 4) & 0xF, erroutput & 0xF);
|
sprintf(hexbuf, "%X%X", (erroutput >> 4) & 0xF, erroutput & 0xF);
|
||||||
XDRGTKRDS += hexbuf;
|
XDRGTKRDS += hexbuf;
|
||||||
XDRGTKRDS += '\n';
|
XDRGTKRDS += F('\n');
|
||||||
|
|
||||||
if (XDRGTKRDS.changed(0)) {
|
if (XDRGTKRDS.changed(0)) {
|
||||||
uint8_t piError = radio.rds.rdsErr >> 14;
|
uint8_t piError = radio.rds.rdsErr >> 14;
|
||||||
@@ -361,15 +366,14 @@ void showPI() {
|
|||||||
else tftReplace(ACENTER, PIold, radio.rds.picode, 275, 75, RDSColor, RDSColorSmooth, BackgroundColor, 28);
|
else tftReplace(ACENTER, PIold, radio.rds.picode, 275, 75, RDSColor, RDSColorSmooth, BackgroundColor, 28);
|
||||||
} else {
|
} else {
|
||||||
if (!RDSstatus) {
|
if (!RDSstatus) {
|
||||||
if (String(radio.rds.picode) != PIold) tftReplace(ALEFT, PIold, radio.rds.picode, 240, 72, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
if (String(radio.rds.picode) != PIold) tftReplace16(ALEFT, PIold, radio.rds.picode, 240, 72, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
|
||||||
tftReplace(ALEFT, stationIDold, radio.rds.stationIDtext, 240, 89, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
tftReplace(ALEFT, stationIDold, radio.rds.stationIDtext, 240, 89, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
||||||
} else {
|
} else {
|
||||||
if (String(radio.rds.picode) != PIold) tftReplace(ALEFT, PIold, radio.rds.picode, 240, 72, RDSColor, RDSColorSmooth, BackgroundColor, 16);
|
if (String(radio.rds.picode) != PIold) tftReplace16(ALEFT, PIold, radio.rds.picode, 240, 72, RDSColor, RDSColorSmooth, BackgroundColor);
|
||||||
tftReplace(ALEFT, stationIDold, radio.rds.stationIDtext, 240, 89, RDSColor, RDSColorSmooth, BackgroundColor, 16);
|
tftReplace(ALEFT, stationIDold, radio.rds.stationIDtext, 240, 89, RDSColor, RDSColorSmooth, BackgroundColor, 16);
|
||||||
|
} tftReplace(ARIGHT, stationStateold, radio.rds.stationStatetext, 318, 89, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
tftReplace(ARIGHT, stationStateold, radio.rds.stationStatetext, 318, 89, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
} else if (afscreen) tftReplace16(ALEFT, PIold, radio.rds.picode, 30, 201, BWAutoColor, BWAutoColorSmooth, BackgroundColor);
|
||||||
}
|
|
||||||
} else if (afscreen) tftReplace(ALEFT, PIold, radio.rds.picode, 30, 201, BWAutoColor, BWAutoColorSmooth, BackgroundColor, 16);
|
|
||||||
else if (!rdsstatscreen) {
|
else if (!rdsstatscreen) {
|
||||||
if (radio.rds.region == 0) {
|
if (radio.rds.region == 0) {
|
||||||
if (!RDSstatus) tftReplace(ACENTER, PIold, radio.rds.picode, 275, 187, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 28);
|
if (!RDSstatus) tftReplace(ACENTER, PIold, radio.rds.picode, 275, 187, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 28);
|
||||||
@@ -377,12 +381,12 @@ void showPI() {
|
|||||||
} else {
|
} else {
|
||||||
if (!RDSstatus) {
|
if (!RDSstatus) {
|
||||||
if (String(radio.rds.picode) != PIold || radio.rds.stationIDtext != stationIDold) {
|
if (String(radio.rds.picode) != PIold || radio.rds.stationIDtext != stationIDold) {
|
||||||
tftReplace(ALEFT, PIold, radio.rds.picode, 240, 184, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
tftReplace16(ALEFT, PIold, radio.rds.picode, 240, 184, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
|
||||||
tftReplace(ALEFT, stationIDold, radio.rds.stationIDtext, 240, 201, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
tftReplace(ALEFT, stationIDold, radio.rds.stationIDtext, 240, 201, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (String(radio.rds.picode) != PIold || radio.rds.stationIDtext != stationIDold) {
|
if (String(radio.rds.picode) != PIold || radio.rds.stationIDtext != stationIDold) {
|
||||||
tftReplace(ALEFT, PIold, radio.rds.picode, 240, 184, RDSColor, RDSColorSmooth, BackgroundColor, 16);
|
tftReplace16(ALEFT, PIold, radio.rds.picode, 240, 184, RDSColor, RDSColorSmooth, BackgroundColor);
|
||||||
tftReplace(ALEFT, stationIDold, radio.rds.stationIDtext, 240, 201, RDSColor, RDSColorSmooth, BackgroundColor, 16);
|
tftReplace(ALEFT, stationIDold, radio.rds.stationIDtext, 240, 201, RDSColor, RDSColorSmooth, BackgroundColor, 16);
|
||||||
tftReplace(ARIGHT, stationStateold, radio.rds.stationStatetext, 318, 201, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
tftReplace(ARIGHT, stationStateold, radio.rds.stationStatetext, 318, 201, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
@@ -404,7 +408,7 @@ void showPI() {
|
|||||||
|
|
||||||
void showPTY() {
|
void showPTY() {
|
||||||
if(radio.rds.PTY.changed(0)) {
|
if(radio.rds.PTY.changed(0)) {
|
||||||
String PTYString = (radio.rds.region != 0 ? (radio.rds.region == 0 ? PTY_EU[radio.rds.PTY] : PTY_USA[radio.rds.PTY]) : textUI(225 + radio.rds.PTY));
|
String PTYString = (radio.rds.region != 0 ? (radio.rds.region == 0 ? PTY_EU[radio.rds.PTY] : PTY_USA[radio.rds.PTY]) : textUI(224 + radio.rds.PTY));
|
||||||
GeneralTextSprite.fillSprite(TFT_TRANSPARENT);
|
GeneralTextSprite.fillSprite(TFT_TRANSPARENT);
|
||||||
GeneralTextSprite.fillRect(0, 0, 160, 19, BackgroundColor);
|
GeneralTextSprite.fillRect(0, 0, 160, 19, BackgroundColor);
|
||||||
if(RDSstatus) GeneralTextSprite.setTextColor(RDSColor, RDSColorSmooth, false);
|
if(RDSstatus) GeneralTextSprite.setTextColor(RDSColor, RDSColorSmooth, false);
|
||||||
@@ -487,10 +491,8 @@ void showCT() {
|
|||||||
char dateStr[9];
|
char dateStr[9];
|
||||||
time_t t = rtc.getEpoch();
|
time_t t = rtc.getEpoch();
|
||||||
|
|
||||||
if (NTPupdated) {
|
t += Timezone * 3600;
|
||||||
t += NTPoffset * 3600; // Convert offset from hours to seconds
|
|
||||||
if (autoDST && isDST(t)) t += 3600;
|
if (autoDST && isDST(t)) t += 3600;
|
||||||
}
|
|
||||||
|
|
||||||
auto localtm = localtime(&t);
|
auto localtm = localtime(&t);
|
||||||
|
|
||||||
@@ -509,17 +511,15 @@ void showCT() {
|
|||||||
if (hour < 0 || hour > 23) hour = 0;
|
if (hour < 0 || hour > 23) hour = 0;
|
||||||
|
|
||||||
snprintf(timeStr, sizeof(timeStr), "%02d:%02d:%02d", hour, localtm->tm_min, localtm->tm_sec);
|
snprintf(timeStr, sizeof(timeStr), "%02d:%02d:%02d", hour, localtm->tm_min, localtm->tm_sec);
|
||||||
|
} rds_clock = String(timeStr);
|
||||||
}
|
|
||||||
rds_clock = String(timeStr);
|
|
||||||
|
|
||||||
if (clockampm) strftime(dateStr, sizeof(dateStr), "%m-%d-%y", localtm);
|
if (clockampm) strftime(dateStr, sizeof(dateStr), "%m-%d-%y", localtm);
|
||||||
else strftime(dateStr, sizeof(dateStr), "%d-%m-%y", localtm);
|
else strftime(dateStr, sizeof(dateStr), "%d-%m-%y", localtm);
|
||||||
rds_date = String(dateStr);
|
rds_date = String(dateStr);
|
||||||
|
|
||||||
if (!screenmute && showclock && (rds_clock != rds_clockold || rds_date != rds_dateold || radio.rds.hasCT.changed(0))) {
|
if (!screenmute && showclock && (rds_clock != rds_clockold || rds_date != rds_dateold || radio.rds.hasCT.changed(0))) {
|
||||||
tftReplace(ACENTER, rds_clockold, rds_clock, 134, 1, RDSColor, RDSColorSmooth, BackgroundColor, 16);
|
tftReplace16(ACENTER, rds_clockold, rds_clock, 134, 1, RDSColor, RDSColorSmooth, BackgroundColor);
|
||||||
tftReplace(ACENTER, rds_dateold, rds_date, 134, 15, RDSColor, RDSColorSmooth, BackgroundColor, 16);
|
tftReplace16(ACENTER, rds_dateold, rds_date, 134, 15, RDSColor, RDSColorSmooth, BackgroundColor);
|
||||||
rds_clockold = rds_clock;
|
rds_clockold = rds_clock;
|
||||||
rds_dateold = rds_date;
|
rds_dateold = rds_date;
|
||||||
}
|
}
|
||||||
@@ -546,11 +546,8 @@ void showRadioText() {
|
|||||||
if (RThex[i] < 0x10) Udp.print("0");
|
if (RThex[i] < 0x10) Udp.print("0");
|
||||||
if (RThex[i] == ' ') RThex[i] = '_';
|
if (RThex[i] == ' ') RThex[i] = '_';
|
||||||
Udp.print(String(RThex[i], HEX));
|
Udp.print(String(RThex[i], HEX));
|
||||||
}
|
} Udp.endPacket();
|
||||||
Udp.endPacket();
|
} RTold = RTString;
|
||||||
}
|
|
||||||
|
|
||||||
RTold = RTString;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,16 +556,16 @@ void ShowAFEON() {
|
|||||||
if (radio.eon_counter > 9) {
|
if (radio.eon_counter > 9) {
|
||||||
if (!afpage) {
|
if (!afpage) {
|
||||||
afpage = true;
|
afpage = true;
|
||||||
tftPrint(ARIGHT, String(afpagenr) + "/2", 315, 201, BackgroundColor, BackgroundColor, 16);
|
tftPrint16(ARIGHT, String(afpagenr) + "/2", 315, 201, BackgroundColor, BackgroundColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (afpage) tftPrint(ARIGHT, String(afpagenr) + "/3", 315, 201, ActiveColor, ActiveColorSmooth, 16); else tftPrint(ARIGHT, String(afpagenr) + "/2", 315, 201, ActiveColor, ActiveColorSmooth, 16);
|
if (afpage) tftPrint16(ARIGHT, String(afpagenr) + "/3", 315, 201, ActiveColor, ActiveColorSmooth); else tftPrint16(ARIGHT, String(afpagenr) + "/2", 315, 201, ActiveColor, ActiveColorSmooth);
|
||||||
|
|
||||||
if (radio.rds.hasAF && afpagenr == 1) {
|
if (radio.rds.hasAF && afpagenr == 1) {
|
||||||
if (!hasafold) {
|
if (!hasafold) {
|
||||||
tftPrint(ALEFT, textUI(84), 6, 48, BackgroundColor, BackgroundColor, 16);
|
tftPrint(ALEFT, textUI(84), 6, 48, BackgroundColor, BackgroundColor, 16);
|
||||||
tftPrint(ALEFT, "AF:", 4, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint16(ALEFT, "AF:", 4, 32, ActiveColor, ActiveColorSmooth);
|
||||||
hasafold = true;
|
hasafold = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,10 +588,10 @@ void ShowAFEON() {
|
|||||||
if (radio.eon_counter > 0 && afpagenr > 1) {
|
if (radio.eon_counter > 0 && afpagenr > 1) {
|
||||||
if (!haseonold) {
|
if (!haseonold) {
|
||||||
tftPrint(ALEFT, textUI(85), 6, 48, BackgroundColor, BackgroundColor, 16);
|
tftPrint(ALEFT, textUI(85), 6, 48, BackgroundColor, BackgroundColor, 16);
|
||||||
tftPrint(ALEFT, "PI", 4, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint16(ALEFT, "PI", 4, 32, ActiveColor, ActiveColorSmooth);
|
||||||
tftPrint(ACENTER, "TA", 250, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint16(ACENTER, "TA", 256, 32, ActiveColor, ActiveColorSmooth);
|
||||||
tftPrint(ACENTER, "TP", 276, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint16(ACENTER, "TP", 282, 32, ActiveColor, ActiveColorSmooth);
|
||||||
tftPrint(ACENTER, "PTY", 304, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint16(ACENTER, "PTY", 310, 32, ActiveColor, ActiveColorSmooth);
|
||||||
haseonold = true;
|
haseonold = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,7 +618,7 @@ void ShowAFEON() {
|
|||||||
strcpy(eonpicodeold[i + y], radio.eon[i + y].picode);
|
strcpy(eonpicodeold[i + y], radio.eon[i + y].picode);
|
||||||
|
|
||||||
if (radio.eon[i + y].ps.length() > 0) {
|
if (radio.eon[i + y].ps.length() > 0) {
|
||||||
tftPrint(ALEFT, "PS", 46, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint16(ALEFT, "PS", 46, 32, ActiveColor, ActiveColorSmooth);
|
||||||
|
|
||||||
if (strcmp(radio.eon[i + y].ps.c_str(), eonpsold[i + y].c_str()) != 0) tftPrint(ALEFT, eonpsold[i + y].c_str(), 46, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
if (strcmp(radio.eon[i + y].ps.c_str(), eonpsold[i + y].c_str()) != 0) tftPrint(ALEFT, eonpsold[i + y].c_str(), 46, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
tftPrint(ALEFT, radio.eon[i + y].ps.c_str(), 46, 48 + (15 * i), RDSDropoutColor, RDSDropoutColorSmooth, 16);
|
tftPrint(ALEFT, radio.eon[i + y].ps.c_str(), 46, 48 + (15 * i), RDSDropoutColor, RDSDropoutColorSmooth, 16);
|
||||||
@@ -629,67 +626,67 @@ void ShowAFEON() {
|
|||||||
} else tftPrint(ALEFT, eonpsold[i + y].c_str(), 46, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
} else tftPrint(ALEFT, eonpsold[i + y].c_str(), 46, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
|
|
||||||
if (radio.eon[i + y].mappedfreq > 0) {
|
if (radio.eon[i + y].mappedfreq > 0) {
|
||||||
tftPrint(ALEFT, "MF", 119, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint(ALEFT, "MF", 125, 32, ActiveColor, ActiveColorSmooth, 16);
|
||||||
|
|
||||||
if (radio.eon[i + y].mappedfreq != mappedfreqold[i + y]) {
|
if (radio.eon[i + y].mappedfreq != mappedfreqold[i + y]) {
|
||||||
char oldFreq[10];
|
char oldFreq[10];
|
||||||
dtostrf(mappedfreqold[i + y] / 100.0, 5, 1, oldFreq);
|
dtostrf(mappedfreqold[i + y] / 100.0, 5, 1, oldFreq);
|
||||||
tftPrint(ALEFT, oldFreq, 115, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
tftPrint(ALEFT, oldFreq, 121, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
char newFreq[10];
|
char newFreq[10];
|
||||||
dtostrf(radio.eon[i + y].mappedfreq / 100.0, 5, 1, newFreq);
|
dtostrf(radio.eon[i + y].mappedfreq / 100.0, 5, 1, newFreq);
|
||||||
tftPrint(ALEFT, newFreq, 115, 48 + (15 * i), RDSDropoutColor, RDSDropoutColorSmooth, 16);
|
tftPrint(ALEFT, newFreq, 121, 48 + (15 * i), RDSDropoutColor, RDSDropoutColorSmooth, 16);
|
||||||
mappedfreqold[i + y] = radio.eon[i + y].mappedfreq;
|
mappedfreqold[i + y] = radio.eon[i + y].mappedfreq;
|
||||||
} else {
|
} else {
|
||||||
char oldFreq[10];
|
char oldFreq[10];
|
||||||
dtostrf(mappedfreqold[i + y] / 100.0, 5, 1, oldFreq);
|
dtostrf(mappedfreqold[i + y] / 100.0, 5, 1, oldFreq);
|
||||||
tftPrint(ALEFT, oldFreq, 115, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
tftPrint(ALEFT, oldFreq, 121, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radio.eon[i + y].mappedfreq2 > 0) {
|
if (radio.eon[i + y].mappedfreq2 > 0) {
|
||||||
tftPrint(ALEFT, "MF2", 162, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint(ALEFT, "MF2", 168, 32, ActiveColor, ActiveColorSmooth, 16);
|
||||||
|
|
||||||
if (radio.eon[i + y].mappedfreq2 != mappedfreqold2[i + y]) {
|
if (radio.eon[i + y].mappedfreq2 != mappedfreqold2[i + y]) {
|
||||||
char oldFreq2[10];
|
char oldFreq2[10];
|
||||||
dtostrf(mappedfreqold2[i + y] / 100.0, 5, 1, oldFreq2);
|
dtostrf(mappedfreqold2[i + y] / 100.0, 5, 1, oldFreq2);
|
||||||
tftPrint(ALEFT, oldFreq2, 160, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
tftPrint(ALEFT, oldFreq2, 166, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
char newFreq2[10];
|
char newFreq2[10];
|
||||||
dtostrf(radio.eon[i + y].mappedfreq2 / 100.0, 5, 1, newFreq2);
|
dtostrf(radio.eon[i + y].mappedfreq2 / 100.0, 5, 1, newFreq2);
|
||||||
tftPrint(ALEFT, newFreq2, 160, 48 + (15 * i), RDSDropoutColor, RDSDropoutColorSmooth, 16);
|
tftPrint(ALEFT, newFreq2, 166, 48 + (15 * i), RDSDropoutColor, RDSDropoutColorSmooth, 16);
|
||||||
mappedfreqold2[i + y] = radio.eon[i + y].mappedfreq2;
|
mappedfreqold2[i + y] = radio.eon[i + y].mappedfreq2;
|
||||||
} else {
|
} else {
|
||||||
char oldFreq2[10];
|
char oldFreq2[10];
|
||||||
dtostrf(mappedfreqold2[i + y] / 100.0, 5, 1, oldFreq2);
|
dtostrf(mappedfreqold2[i + y] / 100.0, 5, 1, oldFreq2);
|
||||||
tftPrint(ALEFT, oldFreq2, 160, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
tftPrint(ALEFT, oldFreq2, 166, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radio.eon[i + y].mappedfreq3 > 0) {
|
if (radio.eon[i + y].mappedfreq3 > 0) {
|
||||||
tftPrint(ALEFT, "MF3", 207, 32, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint(ALEFT, "MF3", 213, 32, ActiveColor, ActiveColorSmooth, 16);
|
||||||
|
|
||||||
if (radio.eon[i + y].mappedfreq3 != mappedfreqold3[i + y]) {
|
if (radio.eon[i + y].mappedfreq3 != mappedfreqold3[i + y]) {
|
||||||
char oldFreq3[10];
|
char oldFreq3[10];
|
||||||
dtostrf(mappedfreqold3[i + y] / 100.0, 5, 1, oldFreq3);
|
dtostrf(mappedfreqold3[i + y] / 100.0, 5, 1, oldFreq3);
|
||||||
tftPrint(ALEFT, oldFreq3, 205, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
tftPrint(ALEFT, oldFreq3, 211, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
char newFreq3[10];
|
char newFreq3[10];
|
||||||
dtostrf(radio.eon[i + y].mappedfreq3 / 100.0, 5, 1, newFreq3);
|
dtostrf(radio.eon[i + y].mappedfreq3 / 100.0, 5, 1, newFreq3);
|
||||||
tftPrint(ALEFT, newFreq3, 205, 48 + (15 * i), RDSDropoutColor, RDSDropoutColorSmooth, 16);
|
tftPrint(ALEFT, newFreq3, 211, 48 + (15 * i), RDSDropoutColor, RDSDropoutColorSmooth, 16);
|
||||||
mappedfreqold3[i + y] = radio.eon[i + y].mappedfreq3;
|
mappedfreqold3[i + y] = radio.eon[i + y].mappedfreq3;
|
||||||
} else {
|
} else {
|
||||||
char oldFreq3[10];
|
char oldFreq3[10];
|
||||||
dtostrf(mappedfreqold3[i + y] / 100.0, 5, 1, oldFreq3);
|
dtostrf(mappedfreqold3[i + y] / 100.0, 5, 1, oldFreq3);
|
||||||
tftPrint(ALEFT, oldFreq3, 205, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
tftPrint(ALEFT, oldFreq3, 211, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radio.eon[i + y].ptyset) {
|
if (radio.eon[i + y].ptyset) {
|
||||||
if (eonptyold[i + y] != radio.eon[i + y].pty) tft.fillRect(290, 48 + (15 * i), 29, 16, BackgroundColor);
|
if (eonptyold[i + y] != radio.eon[i + y].pty) tft.fillRect(296, 48 + (15 * i), 24, 16, BackgroundColor);
|
||||||
if (radio.eon[i + y].pty != 254) tftPrint(ARIGHT, String(radio.eon[i + y].pty), 310, 48 + (15 * i), RDSColor, RDSColorSmooth, 16);
|
if (radio.eon[i + y].pty != 254) tftPrint(ARIGHT, String(radio.eon[i + y].pty), 316, 48 + (15 * i), RDSColor, RDSColorSmooth, 16);
|
||||||
eonptyold[i + y] = radio.eon[i + y].pty;
|
eonptyold[i + y] = radio.eon[i + y].pty;
|
||||||
} else tft.fillRect(290, 48 + (15 * i), 29, 16, BackgroundColor);
|
} else tft.fillRect(296, 48 + (15 * i), 24, 16, BackgroundColor);
|
||||||
|
|
||||||
if (radio.eon[i + y].ta) tftPrint(ACENTER, "O", 250, 48 + (15 * i), RDSColor, RDSColorSmooth, 16); else tftPrint(ACENTER, "O", 250, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
if (radio.eon[i + y].ta) tftPrint(ACENTER, "O", 256, 48 + (15 * i), RDSColor, RDSColorSmooth, 16); else tftPrint(ACENTER, "O", 250, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
if (radio.eon[i + y].tp) tftPrint(ACENTER, "O", 276, 48 + (15 * i), RDSColor, RDSColorSmooth, 16); else tftPrint(ACENTER, "O", 276, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
if (radio.eon[i + y].tp) tftPrint(ACENTER, "O", 282, 48 + (15 * i), RDSColor, RDSColorSmooth, 16); else tftPrint(ACENTER, "O", 276, 48 + (15 * i), BackgroundColor, BackgroundColor, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -709,8 +706,7 @@ void ShowAFEON() {
|
|||||||
uint8_t nibble = (radio.rds.aid[y] >> (4 * (3 - z))) & 0xF;
|
uint8_t nibble = (radio.rds.aid[y] >> (4 * (3 - z))) & 0xF;
|
||||||
if (nibble < 10) id[z] = nibble + '0';
|
if (nibble < 10) id[z] = nibble + '0';
|
||||||
else id[z] = nibble - 10 + 'A';
|
else id[z] = nibble - 10 + 'A';
|
||||||
}
|
} id[4] = '\0';
|
||||||
id[4] = '\0';
|
|
||||||
|
|
||||||
AIDStringTemp += String(id);
|
AIDStringTemp += String(id);
|
||||||
AIDStringTemp += ": ";
|
AIDStringTemp += ": ";
|
||||||
@@ -731,9 +727,7 @@ void ShowAFEON() {
|
|||||||
AIDWidth = FullLineSprite.textWidth(AIDString);
|
AIDWidth = FullLineSprite.textWidth(AIDString);
|
||||||
AIDStringold = AIDString;
|
AIDStringold = AIDString;
|
||||||
}
|
}
|
||||||
}
|
} aidDisplay.update(AIDString, true, ActiveColor, ActiveColorSmooth, 0, 0, BackgroundColor);
|
||||||
|
|
||||||
aidDisplay.update(AIDString, true, ActiveColor, ActiveColorSmooth, 0, 0, BackgroundColor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,7 +776,7 @@ void ShowRDSStatistics() {
|
|||||||
if (lastX >= 0 && (lastX != xpos || lastY != ypos)) tft.fillCircle(lastX - 55, lastY + 7, 2, SignificantColor);
|
if (lastX >= 0 && (lastX != xpos || lastY != ypos)) tft.fillCircle(lastX - 55, lastY + 7, 2, SignificantColor);
|
||||||
|
|
||||||
tftReplace(ARIGHT, oldBuf, newBuf, xpos, ypos, PrimaryColor, PrimaryColorSmooth, BackgroundColor, 16);
|
tftReplace(ARIGHT, oldBuf, newBuf, xpos, ypos, PrimaryColor, PrimaryColorSmooth, BackgroundColor, 16);
|
||||||
tftPrint(ACENTER, "%", xposPct, ypos, ActiveColor, ActiveColorSmooth, 16);
|
tftPrint(ACENTER, F("%"), xposPct, ypos, ActiveColor, ActiveColorSmooth, 16);
|
||||||
|
|
||||||
tft.fillCircle(xpos - 55, ypos + 7, 2, InsignificantColor);
|
tft.fillCircle(xpos - 55, ypos + 7, 2, InsignificantColor);
|
||||||
|
|
||||||
@@ -794,11 +788,11 @@ void ShowRDSStatistics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String HexString = String(((radio.rds.rdsA >> 12) & 0xF), HEX) + String(((radio.rds.rdsA >> 8) & 0xF), HEX) + String(((radio.rds.rdsA >> 4) & 0xF), HEX) + String((radio.rds.rdsA & 0xF), HEX);
|
String HexString = String(((radio.rds.rdsA >> 12) & 0xF), HEX) + String(((radio.rds.rdsA >> 8) & 0xF), HEX) + String(((radio.rds.rdsA >> 4) & 0xF), HEX) + String((radio.rds.rdsA & 0xF), HEX);
|
||||||
HexString += " ";
|
HexString += F(" ");
|
||||||
HexString += String(((radio.rds.rdsB >> 12) & 0xF), HEX) + String(((radio.rds.rdsB >> 8) & 0xF), HEX) + String(((radio.rds.rdsB >> 4) & 0xF), HEX) + String((radio.rds.rdsB & 0xF), HEX);
|
HexString += String(((radio.rds.rdsB >> 12) & 0xF), HEX) + String(((radio.rds.rdsB >> 8) & 0xF), HEX) + String(((radio.rds.rdsB >> 4) & 0xF), HEX) + String((radio.rds.rdsB & 0xF), HEX);
|
||||||
HexString += " ";
|
HexString += F(" ");
|
||||||
HexString += String(((radio.rds.rdsC >> 12) & 0xF), HEX) + String(((radio.rds.rdsC >> 8) & 0xF), HEX) + String(((radio.rds.rdsC >> 4) & 0xF), HEX) + String((radio.rds.rdsC & 0xF), HEX);
|
HexString += String(((radio.rds.rdsC >> 12) & 0xF), HEX) + String(((radio.rds.rdsC >> 8) & 0xF), HEX) + String(((radio.rds.rdsC >> 4) & 0xF), HEX) + String((radio.rds.rdsC & 0xF), HEX);
|
||||||
HexString += " ";
|
HexString += F(" ");
|
||||||
HexString += String(((radio.rds.rdsD >> 12) & 0xF), HEX) + String(((radio.rds.rdsD >> 8) & 0xF), HEX) + String(((radio.rds.rdsD >> 4) & 0xF), HEX) + String((radio.rds.rdsD & 0xF), HEX);
|
HexString += String(((radio.rds.rdsD >> 12) & 0xF), HEX) + String(((radio.rds.rdsD >> 8) & 0xF), HEX) + String(((radio.rds.rdsD >> 4) & 0xF), HEX) + String((radio.rds.rdsD & 0xF), HEX);
|
||||||
HexString.toUpperCase();
|
HexString.toUpperCase();
|
||||||
|
|
||||||
@@ -809,7 +803,7 @@ void ShowRDSStatistics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (radio.processed_rdsblocks > 0 && !dropout) {
|
if (radio.processed_rdsblocks > 0 && !dropout) {
|
||||||
const uint8_t xErr[4] = {86, 124, 162, 200};
|
constexpr uint8_t xErr[4] = {86, 124, 162, 200};
|
||||||
const bool errors[4] = {radio.rds.rdsAerror, radio.rds.rdsBerror, radio.rds.rdsCerror, radio.rds.rdsDerror};
|
const bool errors[4] = {radio.rds.rdsAerror, radio.rds.rdsBerror, radio.rds.rdsCerror, radio.rds.rdsDerror};
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 4; i++) tft.fillCircle(xErr[i], 41, 5, errors[i] ? SignificantColor : InsignificantColor);
|
for (uint8_t i = 0; i < 4; i++) tft.fillCircle(xErr[i], 41, 5, errors[i] ? SignificantColor : InsignificantColor);
|
||||||
@@ -819,22 +813,22 @@ void ShowRDSStatistics() {
|
|||||||
int errC = ((radio.rds.rdsErr >> 8) & 12) >> 2;
|
int errC = ((radio.rds.rdsErr >> 8) & 12) >> 2;
|
||||||
int errD = (radio.rds.rdsErr & 3);
|
int errD = (radio.rds.rdsErr & 3);
|
||||||
|
|
||||||
const int weights[4] = {0, 2, 6, 12};
|
constexpr int weights[4] = {0, 2, 6, 12};
|
||||||
|
|
||||||
int errorBits = weights[errA] + weights[errB] + weights[errC] + weights[errD];
|
int errorBits = weights[errA] + weights[errB] + weights[errC] + weights[errD];
|
||||||
int totalBits = 4 * 26;
|
constexpr int totalBits = 4 * 26;
|
||||||
|
|
||||||
float ber = (float)errorBits / (float)totalBits;
|
float ber = (float)errorBits / (float)totalBits;
|
||||||
|
|
||||||
ber = sqrt(ber);
|
ber = sqrt(ber);
|
||||||
if (ber > 1.0) ber = 1.0;
|
if (ber > 1.0) ber = 1.0;
|
||||||
|
|
||||||
float alpha = 0.05;
|
constexpr float alpha = 0.05;
|
||||||
smoothBER = (1.0 - alpha) * smoothBER + alpha * ber;
|
smoothBER = (1.0 - alpha) * smoothBER + alpha * ber;
|
||||||
|
|
||||||
int berPercent = (int)(smoothBER * 100.0);
|
int berPercent = (int)(smoothBER * 100.0);
|
||||||
if (berPercentold != berPercent) {
|
if (berPercentold != berPercent) {
|
||||||
tftReplace(ARIGHT, String(berPercentold) + "%", String(berPercent) + "%", 318, 34, PrimaryColor, PrimaryColorSmooth, BackgroundColor, 16);
|
tftReplace(ARIGHT, String(berPercentold) + F("%"), String(berPercent) + F("%"), 318, 34, PrimaryColor, PrimaryColorSmooth, BackgroundColor, 16);
|
||||||
berPercentold = berPercent;
|
berPercentold = berPercent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-5
@@ -1,4 +1,6 @@
|
|||||||
#include "rtc.hpp"
|
#include "rtc.hpp"
|
||||||
|
#include "globals.h"
|
||||||
|
#include "nonvolatile.h"
|
||||||
|
|
||||||
// the hardware rtc driver was made with the support of Wh1teRabbitHU's implementation
|
// the hardware rtc driver was made with the support of Wh1teRabbitHU's implementation
|
||||||
|
|
||||||
@@ -45,6 +47,9 @@ inline byte sumValueFromBinary(byte binary, byte length) {
|
|||||||
|
|
||||||
void sync_from_rx_rtc(int32_t offset = 0) {
|
void sync_from_rx_rtc(int32_t offset = 0) {
|
||||||
if(!rx_rtc_avail) return;
|
if(!rx_rtc_avail) return;
|
||||||
|
auto old_clock = Wire.getClock();
|
||||||
|
Wire.setClock(400000);
|
||||||
|
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
memset(&timeinfo, 0, sizeof(timeinfo));
|
memset(&timeinfo, 0, sizeof(timeinfo));
|
||||||
|
|
||||||
@@ -66,10 +71,12 @@ void sync_from_rx_rtc(int32_t offset = 0) {
|
|||||||
|
|
||||||
timeinfo.tm_mday = sumValueFromBinary(Wire.read(), 6);
|
timeinfo.tm_mday = sumValueFromBinary(Wire.read(), 6);
|
||||||
timeinfo.tm_mon = sumValueFromBinary(Wire.read(), 5) - 1;
|
timeinfo.tm_mon = sumValueFromBinary(Wire.read(), 5) - 1;
|
||||||
timeinfo.tm_year = sumValueFromBinary(Wire.read(), 8) + 100;
|
timeinfo.tm_year = sumValueFromBinary(Wire.read(), 8) + 126;
|
||||||
|
|
||||||
rtc.setTime(mktime(&timeinfo) + offset);
|
rtc.setTime(mktime(&timeinfo) + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Wire.setClock(old_clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool init_rtc() {
|
bool init_rtc() {
|
||||||
@@ -102,7 +109,7 @@ bool init_rtc() {
|
|||||||
Wire.write(1 << 2);
|
Wire.write(1 << 2);
|
||||||
Wire.write(toBCD(14));
|
Wire.write(toBCD(14));
|
||||||
Wire.write(1);
|
Wire.write(1);
|
||||||
Wire.write(toBCD(26));
|
Wire.write(0);
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
writeToModule(0x1F, 0); // Unset stop bit
|
writeToModule(0x1F, 0); // Unset stop bit
|
||||||
return true;
|
return true;
|
||||||
@@ -111,12 +118,18 @@ bool init_rtc() {
|
|||||||
writeToModule(0x1F, 0);
|
writeToModule(0x1F, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sync_from_rx_rtc();
|
sync_from_rx_rtc(1); // mystery offset, without it the time is offset by one second
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_time(time_t time) {
|
void set_time(time_t time, int8_t offset) {
|
||||||
rtc.setTime(time);
|
rtc.setTime(time);
|
||||||
|
if(Timezone != offset) {
|
||||||
|
EEPROM.writeByte(EE_BYTE_TIMEZONE, offset);
|
||||||
|
EEPROM.commit();
|
||||||
|
Timezone = offset;
|
||||||
|
}
|
||||||
|
|
||||||
if(!rx_rtc_avail) return;
|
if(!rx_rtc_avail) return;
|
||||||
struct tm* timeinfo = gmtime(&time);
|
struct tm* timeinfo = gmtime(&time);
|
||||||
writeToModule(0x1F, 64);
|
writeToModule(0x1F, 64);
|
||||||
@@ -128,7 +141,7 @@ void set_time(time_t time) {
|
|||||||
Wire.write(1 << timeinfo->tm_wday);
|
Wire.write(1 << timeinfo->tm_wday);
|
||||||
Wire.write(toBCD(timeinfo->tm_mday));
|
Wire.write(toBCD(timeinfo->tm_mday));
|
||||||
Wire.write(toBCD(timeinfo->tm_mon + 1));
|
Wire.write(toBCD(timeinfo->tm_mon + 1));
|
||||||
Wire.write(toBCD((1900 + timeinfo->tm_year) % 100));
|
Wire.write(toBCD((1900 + timeinfo->tm_year - 26) % 100));
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
writeToModule(0x1F, 0);
|
writeToModule(0x1F, 0);
|
||||||
}
|
}
|
||||||
+5
-10
@@ -159,11 +159,9 @@ void doTouchEvent(uint16_t x, uint16_t y) {
|
|||||||
doBW();
|
doBW();
|
||||||
BWtune = false;
|
BWtune = false;
|
||||||
bwtouchtune = false;
|
bwtouchtune = false;
|
||||||
if (advancedRDS) {
|
if (advancedRDS) BuildAdvancedRDS();
|
||||||
BuildAdvancedRDS();
|
else if (afscreen) BuildAFScreen();
|
||||||
} else if (afscreen) {
|
else {
|
||||||
BuildAFScreen();
|
|
||||||
} else {
|
|
||||||
BuildDisplay();
|
BuildDisplay();
|
||||||
SelectBand();
|
SelectBand();
|
||||||
}
|
}
|
||||||
@@ -173,8 +171,7 @@ void doTouchEvent(uint16_t x, uint16_t y) {
|
|||||||
showBWSelector();
|
showBWSelector();
|
||||||
doBW();
|
doBW();
|
||||||
bwtouchtune = false;
|
bwtouchtune = false;
|
||||||
}
|
} return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BWtune && !menu && !advancedRDS && !seek && !afscreen) {
|
if (!BWtune && !menu && !advancedRDS && !seek && !afscreen) {
|
||||||
@@ -188,9 +185,7 @@ void doTouchEvent(uint16_t x, uint16_t y) {
|
|||||||
} else if (x > 0 && x < 30 && y > 25 && y < 90) {
|
} else if (x > 0 && x < 30 && y > 25 && y < 90) {
|
||||||
doTuneMode();
|
doTuneMode();
|
||||||
return;
|
return;
|
||||||
} else if (x > 250 && x < 320 && y > 50 && y < 80) {
|
} else if (x > 250 && x < 320 && y > 50 && y < 80) toggleiMSEQ();
|
||||||
toggleiMSEQ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BWtune && !menu && advancedRDS && !seek && !afscreen) {
|
if (!BWtune && !menu && advancedRDS && !seek && !afscreen) {
|
||||||
|
|||||||
+2
-4
@@ -96,8 +96,7 @@ String ucs2ToUtf8(const char* ucs2Input) {
|
|||||||
utf8Output += (char)(0x80 | ((ucs2Char >> 6) & 0x3F));
|
utf8Output += (char)(0x80 | ((ucs2Char >> 6) & 0x3F));
|
||||||
utf8Output += (char)(0x80 | (ucs2Char & 0x3F));
|
utf8Output += (char)(0x80 | (ucs2Char & 0x3F));
|
||||||
}
|
}
|
||||||
}
|
} return utf8Output;
|
||||||
return utf8Output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String extractUTF8Substring(const String & utf8String, size_t start, size_t length, bool underscore) {
|
String extractUTF8Substring(const String & utf8String, size_t start, size_t length, bool underscore) {
|
||||||
@@ -133,6 +132,5 @@ String removeNewline(String inputString) {
|
|||||||
for (int i = 0; i < inputString.length(); i++) {
|
for (int i = 0; i < inputString.length(); i++) {
|
||||||
if (inputString[i] == '\n') outputString += ' ';
|
if (inputString[i] == '\n') outputString += ' ';
|
||||||
else outputString += inputString[i];
|
else outputString += inputString[i];
|
||||||
}
|
} return outputString;
|
||||||
return outputString;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user