Compare commits
19
Commits
v0.0.0
..
42aa5fa315
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42aa5fa315 | ||
|
|
ab7148be42 | ||
|
|
3806fd7ee8 | ||
|
|
5bb6b05002 | ||
|
|
b594d6fcb3 | ||
|
|
af93abb8cb | ||
|
|
7e00a6d950 | ||
|
|
beb7f0bfb9 | ||
|
|
1343618729 | ||
|
|
a6f435216a | ||
|
|
a4cf115bd6 | ||
|
|
06dbb8155e | ||
|
|
7d2ddcbbdd | ||
|
|
14d40633f2 | ||
|
|
3561117a56 | ||
|
|
fd351d0934 | ||
|
|
e54f3b469d | ||
|
|
0b816aca68 | ||
|
|
afdbbeb233 |
@@ -0,0 +1,8 @@
|
|||||||
|
menu "BLK_BOX Config"
|
||||||
|
config USE_NEW_DISPLAY
|
||||||
|
bool "use new TFT display"
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
Whether or not you have a new TFT display.
|
||||||
|
Incorrectly selecting may result in wrong colors.
|
||||||
|
endmenu
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
"all.cpp"
|
||||||
"TM1640/TM16xx.cpp"
|
"TM1640/TM16xx.cpp"
|
||||||
"TM1640/TM1640.cpp"
|
"TM1640/TM1640.cpp"
|
||||||
|
"SparkFunBQ27441/SparkFunBQ27441.cpp"
|
||||||
|
"esp_lcd_ili9488/esp_lcd_ili9488.c"
|
||||||
"bottom_half.cpp"
|
"bottom_half.cpp"
|
||||||
"char_lcd.cpp"
|
"char_lcd.cpp"
|
||||||
"game_timer.cpp"
|
"game_timer.cpp"
|
||||||
|
"i2c_lcd_pcf8574.c"
|
||||||
"leds.cpp"
|
"leds.cpp"
|
||||||
|
"power.cpp"
|
||||||
"sd.cpp"
|
"sd.cpp"
|
||||||
"speaker.cpp"
|
"speaker.cpp"
|
||||||
"sseg.cpp"
|
"sseg.cpp"
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
// Modified or adapted from https://github.com/sparkfun/SparkFun_BQ27441_Arduino_Library
|
||||||
|
//
|
||||||
|
// Originally Licensed under the MIT
|
||||||
|
/*
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 SparkFun Electronics, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
/******************************************************************************
|
||||||
|
BQ27441_Definitions.h
|
||||||
|
BQ27441 LiPo Fuel Gauge Definitions
|
||||||
|
Jim Lindblom @ SparkFun Electronics
|
||||||
|
May 9, 2016
|
||||||
|
https://github.com/sparkfun/SparkFun_BQ27441_Arduino_Library
|
||||||
|
|
||||||
|
BQ27441 hardware constants, register addresses, and bit positions.
|
||||||
|
|
||||||
|
Hardware Resources:
|
||||||
|
- Arduino Development Board
|
||||||
|
- SparkFun Battery Babysitter
|
||||||
|
|
||||||
|
Development environment specifics:
|
||||||
|
Arduino 1.6.7
|
||||||
|
SparkFun Battery Babysitter v1.0
|
||||||
|
Arduino Uno (any 'duino should do)
|
||||||
|
******************************************************************************/
|
||||||
|
#define BQ72441_I2C_ADDRESS 0x55 // Default I2C address of the BQ27441-G1A
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
// General Constants //
|
||||||
|
///////////////////////
|
||||||
|
#define BQ27441_UNSEAL_KEY 0x8000 // Secret code to unseal the BQ27441-G1A
|
||||||
|
#define BQ27441_DEVICE_ID 0x0421 // Default device ID
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
// Standard Commands //
|
||||||
|
///////////////////////
|
||||||
|
// The fuel gauge uses a series of 2-byte standard commands to enable system
|
||||||
|
// reading and writing of battery information. Each command has an associated
|
||||||
|
// sequential command-code pair.
|
||||||
|
#define BQ27441_COMMAND_CONTROL 0x00 // Control()
|
||||||
|
#define BQ27441_COMMAND_TEMP 0x02 // Temperature()
|
||||||
|
#define BQ27441_COMMAND_VOLTAGE 0x04 // Voltage()
|
||||||
|
#define BQ27441_COMMAND_FLAGS 0x06 // Flags()
|
||||||
|
#define BQ27441_COMMAND_NOM_CAPACITY 0x08 // NominalAvailableCapacity()
|
||||||
|
#define BQ27441_COMMAND_AVAIL_CAPACITY 0x0A // FullAvailableCapacity()
|
||||||
|
#define BQ27441_COMMAND_REM_CAPACITY 0x0C // RemainingCapacity()
|
||||||
|
#define BQ27441_COMMAND_FULL_CAPACITY 0x0E // FullChargeCapacity()
|
||||||
|
#define BQ27441_COMMAND_AVG_CURRENT 0x10 // AverageCurrent()
|
||||||
|
#define BQ27441_COMMAND_STDBY_CURRENT 0x12 // StandbyCurrent()
|
||||||
|
#define BQ27441_COMMAND_MAX_CURRENT 0x14 // MaxLoadCurrent()
|
||||||
|
#define BQ27441_COMMAND_AVG_POWER 0x18 // AveragePower()
|
||||||
|
#define BQ27441_COMMAND_SOC 0x1C // StateOfCharge()
|
||||||
|
#define BQ27441_COMMAND_INT_TEMP 0x1E // InternalTemperature()
|
||||||
|
#define BQ27441_COMMAND_SOH 0x20 // StateOfHealth()
|
||||||
|
#define BQ27441_COMMAND_REM_CAP_UNFL 0x28 // RemainingCapacityUnfiltered()
|
||||||
|
#define BQ27441_COMMAND_REM_CAP_FIL 0x2A // RemainingCapacityFiltered()
|
||||||
|
#define BQ27441_COMMAND_FULL_CAP_UNFL 0x2C // FullChargeCapacityUnfiltered()
|
||||||
|
#define BQ27441_COMMAND_FULL_CAP_FIL 0x2E // FullChargeCapacityFiltered()
|
||||||
|
#define BQ27441_COMMAND_SOC_UNFL 0x30 // StateOfChargeUnfiltered()
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
// Control Sub-commands //
|
||||||
|
//////////////////////////
|
||||||
|
// Issuing a Control() command requires a subsequent 2-byte subcommand. These
|
||||||
|
// additional bytes specify the particular control function desired. The
|
||||||
|
// Control() command allows the system to control specific features of the fuel
|
||||||
|
// gauge during normal operation and additional features when the device is in
|
||||||
|
// different access modes.
|
||||||
|
#define BQ27441_CONTROL_STATUS 0x00
|
||||||
|
#define BQ27441_CONTROL_DEVICE_TYPE 0x01
|
||||||
|
#define BQ27441_CONTROL_FW_VERSION 0x02
|
||||||
|
#define BQ27441_CONTROL_DM_CODE 0x04
|
||||||
|
#define BQ27441_CONTROL_PREV_MACWRITE 0x07
|
||||||
|
#define BQ27441_CONTROL_CHEM_ID 0x08
|
||||||
|
#define BQ27441_CONTROL_BAT_INSERT 0x0C
|
||||||
|
#define BQ27441_CONTROL_BAT_REMOVE 0x0D
|
||||||
|
#define BQ27441_CONTROL_SET_HIBERNATE 0x11
|
||||||
|
#define BQ27441_CONTROL_CLEAR_HIBERNATE 0x12
|
||||||
|
#define BQ27441_CONTROL_SET_CFGUPDATE 0x13
|
||||||
|
#define BQ27441_CONTROL_SHUTDOWN_ENABLE 0x1B
|
||||||
|
#define BQ27441_CONTROL_SHUTDOWN 0x1C
|
||||||
|
#define BQ27441_CONTROL_SEALED 0x20
|
||||||
|
#define BQ27441_CONTROL_PULSE_SOC_INT 0x23
|
||||||
|
#define BQ27441_CONTROL_RESET 0x41
|
||||||
|
#define BQ27441_CONTROL_SOFT_RESET 0x42
|
||||||
|
#define BQ27441_CONTROL_EXIT_CFGUPDATE 0x43
|
||||||
|
#define BQ27441_CONTROL_EXIT_RESIM 0x44
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// Control Status Word - Bit Definitions //
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// Bit positions for the 16-bit data of CONTROL_STATUS.
|
||||||
|
// CONTROL_STATUS instructs the fuel gauge to return status information to
|
||||||
|
// Control() addresses 0x00 and 0x01. The read-only status word contains status
|
||||||
|
// bits that are set or cleared either automatically as conditions warrant or
|
||||||
|
// through using specified subcommands.
|
||||||
|
#define BQ27441_STATUS_SHUTDOWNEN (1<<15)
|
||||||
|
#define BQ27441_STATUS_WDRESET (1<<14)
|
||||||
|
#define BQ27441_STATUS_SS (1<<13)
|
||||||
|
#define BQ27441_STATUS_CALMODE (1<<12)
|
||||||
|
#define BQ27441_STATUS_CCA (1<<11)
|
||||||
|
#define BQ27441_STATUS_BCA (1<<10)
|
||||||
|
#define BQ27441_STATUS_QMAX_UP (1<<9)
|
||||||
|
#define BQ27441_STATUS_RES_UP (1<<8)
|
||||||
|
#define BQ27441_STATUS_INITCOMP (1<<7)
|
||||||
|
#define BQ27441_STATUS_HIBERNATE (1<<6)
|
||||||
|
#define BQ27441_STATUS_SLEEP (1<<4)
|
||||||
|
#define BQ27441_STATUS_LDMD (1<<3)
|
||||||
|
#define BQ27441_STATUS_RUP_DIS (1<<2)
|
||||||
|
#define BQ27441_STATUS_VOK (1<<1)
|
||||||
|
|
||||||
|
////////////////////////////////////
|
||||||
|
// Flag Command - Bit Definitions //
|
||||||
|
////////////////////////////////////
|
||||||
|
// Bit positions for the 16-bit data of Flags()
|
||||||
|
// This read-word function returns the contents of the fuel gauging status
|
||||||
|
// register, depicting the current operating status.
|
||||||
|
#define BQ27441_FLAG_OT (1<<15)
|
||||||
|
#define BQ27441_FLAG_UT (1<<14)
|
||||||
|
#define BQ27441_FLAG_FC (1<<9)
|
||||||
|
#define BQ27441_FLAG_CHG (1<<8)
|
||||||
|
#define BQ27441_FLAG_OCVTAKEN (1<<7)
|
||||||
|
#define BQ27441_FLAG_ITPOR (1<<5)
|
||||||
|
#define BQ27441_FLAG_CFGUPMODE (1<<4)
|
||||||
|
#define BQ27441_FLAG_BAT_DET (1<<3)
|
||||||
|
#define BQ27441_FLAG_SOC1 (1<<2)
|
||||||
|
#define BQ27441_FLAG_SOCF (1<<1)
|
||||||
|
#define BQ27441_FLAG_DSG (1<<0)
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// Extended Data Commands //
|
||||||
|
////////////////////////////
|
||||||
|
// Extended data commands offer additional functionality beyond the standard
|
||||||
|
// set of commands. They are used in the same manner; however, unlike standard
|
||||||
|
// commands, extended commands are not limited to 2-byte words.
|
||||||
|
#define BQ27441_EXTENDED_OPCONFIG 0x3A // OpConfig()
|
||||||
|
#define BQ27441_EXTENDED_CAPACITY 0x3C // DesignCapacity()
|
||||||
|
#define BQ27441_EXTENDED_DATACLASS 0x3E // DataClass()
|
||||||
|
#define BQ27441_EXTENDED_DATABLOCK 0x3F // DataBlock()
|
||||||
|
#define BQ27441_EXTENDED_BLOCKDATA 0x40 // BlockData()
|
||||||
|
#define BQ27441_EXTENDED_CHECKSUM 0x60 // BlockDataCheckSum()
|
||||||
|
#define BQ27441_EXTENDED_CONTROL 0x61 // BlockDataControl()
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// Configuration Class, Subclass ID's //
|
||||||
|
////////////////////////////////////////
|
||||||
|
// To access a subclass of the extended data, set the DataClass() function
|
||||||
|
// with one of these values.
|
||||||
|
// Configuration Classes
|
||||||
|
#define BQ27441_ID_SAFETY 2 // Safety
|
||||||
|
#define BQ27441_ID_CHG_TERMINATION 36 // Charge Termination
|
||||||
|
#define BQ27441_ID_CONFIG_DATA 48 // Data
|
||||||
|
#define BQ27441_ID_DISCHARGE 49 // Discharge
|
||||||
|
#define BQ27441_ID_REGISTERS 64 // Registers
|
||||||
|
#define BQ27441_ID_POWER 68 // Power
|
||||||
|
// Gas Gauging Classes
|
||||||
|
#define BQ27441_ID_IT_CFG 80 // IT Cfg
|
||||||
|
#define BQ27441_ID_CURRENT_THRESH 81 // Current Thresholds
|
||||||
|
#define BQ27441_ID_STATE 82 // State
|
||||||
|
// Ra Tables Classes
|
||||||
|
#define BQ27441_ID_R_A_RAM 89 // R_a RAM
|
||||||
|
// Calibration Classes
|
||||||
|
#define BQ27441_ID_CALIB_DATA 104 // Data
|
||||||
|
#define BQ27441_ID_CC_CAL 105 // CC Cal
|
||||||
|
#define BQ27441_ID_CURRENT 107 // Current
|
||||||
|
// Security Classes
|
||||||
|
#define BQ27441_ID_CODES 112 // Codes
|
||||||
|
|
||||||
|
/////////////////////////////////////////
|
||||||
|
// OpConfig Register - Bit Definitions //
|
||||||
|
/////////////////////////////////////////
|
||||||
|
// Bit positions of the OpConfig Register
|
||||||
|
#define BQ27441_OPCONFIG_BIE (1<<13)
|
||||||
|
#define BQ27441_OPCONFIG_BI_PU_EN (1<<12)
|
||||||
|
#define BQ27441_OPCONFIG_GPIOPOL (1<<11)
|
||||||
|
#define BQ27441_OPCONFIG_SLEEP (1<<5)
|
||||||
|
#define BQ27441_OPCONFIG_RMFCC (1<<4)
|
||||||
|
#define BQ27441_OPCONFIG_BATLOWEN (1<<2)
|
||||||
|
#define BQ27441_OPCONFIG_TEMPS (1<<0)
|
||||||
@@ -0,0 +1,734 @@
|
|||||||
|
// Modified or adapted from https://github.com/sparkfun/SparkFun_BQ27441_Arduino_Library
|
||||||
|
//
|
||||||
|
// Originally Licensed under the MIT
|
||||||
|
/*
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 SparkFun Electronics, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
/******************************************************************************
|
||||||
|
SparkFunBQ27441.cpp
|
||||||
|
BQ27441 Arduino Library Main Source File
|
||||||
|
Jim Lindblom @ SparkFun Electronics
|
||||||
|
May 9, 2016
|
||||||
|
https://github.com/sparkfun/SparkFun_BQ27441_Arduino_Library
|
||||||
|
|
||||||
|
Implementation of all features of the BQ27441 LiPo Fuel Gauge.
|
||||||
|
|
||||||
|
Hardware Resources:
|
||||||
|
- Arduino Development Board
|
||||||
|
- SparkFun Battery Babysitter
|
||||||
|
|
||||||
|
Development environment specifics:
|
||||||
|
Arduino 1.6.7
|
||||||
|
SparkFun Battery Babysitter v1.0
|
||||||
|
Arduino Uno (any 'duino should do)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "SparkFunBQ27441.h"
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
************************** Initialization Functions *************************
|
||||||
|
*****************************************************************************/
|
||||||
|
// Initializes class variables
|
||||||
|
BQ27441::BQ27441() : _deviceAddress(BQ72441_I2C_ADDRESS), _sealFlag(false), _userConfigControl(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t constrain(uint8_t x, uint8_t min, uint8_t max) {
|
||||||
|
if (x < min) return min;
|
||||||
|
if (x > max) return max;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initializes I2C and verifies communication with the BQ27441.
|
||||||
|
bool BQ27441::begin(void)
|
||||||
|
{
|
||||||
|
uint16_t deviceID = 0;
|
||||||
|
|
||||||
|
// Assume the I2C is already initialized from other things
|
||||||
|
|
||||||
|
deviceID = deviceType(); // Read deviceType from BQ27441
|
||||||
|
|
||||||
|
if (deviceID == BQ27441_DEVICE_ID)
|
||||||
|
{
|
||||||
|
return true; // If device ID is valid, return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // Otherwise return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configures the design capacity of the connected battery.
|
||||||
|
bool BQ27441::setCapacity(uint16_t capacity)
|
||||||
|
{
|
||||||
|
// Write to STATE subclass (82) of BQ27441 extended memory.
|
||||||
|
// Offset 0x0A (10)
|
||||||
|
// Design capacity is a 2-byte piece of data - MSB first
|
||||||
|
// Unit: mAh
|
||||||
|
uint8_t capMSB = capacity >> 8;
|
||||||
|
uint8_t capLSB = capacity & 0x00FF;
|
||||||
|
uint8_t capacityData[2] = {capMSB, capLSB};
|
||||||
|
return writeExtendedData(BQ27441_ID_STATE, 10, capacityData, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configures the design energy of the connected battery.
|
||||||
|
bool BQ27441::setDesignEnergy(uint16_t energy)
|
||||||
|
{
|
||||||
|
// Write to STATE subclass (82) of BQ27441 extended memory.
|
||||||
|
// Offset 0x0C (12)
|
||||||
|
// Design energy is a 2-byte piece of data - MSB first
|
||||||
|
// Unit: mWh
|
||||||
|
uint8_t enMSB = energy >> 8;
|
||||||
|
uint8_t enLSB = energy & 0x00FF;
|
||||||
|
uint8_t energyData[2] = {enMSB, enLSB};
|
||||||
|
return writeExtendedData(BQ27441_ID_STATE, 12, energyData, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configures the terminate voltage.
|
||||||
|
bool BQ27441::setTerminateVoltage(uint16_t voltage)
|
||||||
|
{
|
||||||
|
// Write to STATE subclass (82) of BQ27441 extended memory.
|
||||||
|
// Offset 0x0F (16)
|
||||||
|
// Termiante voltage is a 2-byte piece of data - MSB first
|
||||||
|
// Unit: mV
|
||||||
|
// Min 2500, Max 3700
|
||||||
|
if(voltage<2500) voltage=2500;
|
||||||
|
if(voltage>3700) voltage=3700;
|
||||||
|
|
||||||
|
uint8_t tvMSB = voltage >> 8;
|
||||||
|
uint8_t tvLSB = voltage & 0x00FF;
|
||||||
|
uint8_t tvData[2] = {tvMSB, tvLSB};
|
||||||
|
return writeExtendedData(BQ27441_ID_STATE, 16, tvData, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configures taper rate of connected battery.
|
||||||
|
bool BQ27441::setTaperRate(uint16_t rate)
|
||||||
|
{
|
||||||
|
// Write to STATE subclass (82) of BQ27441 extended memory.
|
||||||
|
// Offset 0x1B (27)
|
||||||
|
// Termiante voltage is a 2-byte piece of data - MSB first
|
||||||
|
// Unit: 0.1h
|
||||||
|
// Max 2000
|
||||||
|
if(rate>2000) rate=2000;
|
||||||
|
uint8_t trMSB = rate >> 8;
|
||||||
|
uint8_t trLSB = rate & 0x00FF;
|
||||||
|
uint8_t trData[2] = {trMSB, trLSB};
|
||||||
|
return writeExtendedData(BQ27441_ID_STATE, 27, trData, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
********************** Battery Characteristics Functions ********************
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
// Reads and returns the battery voltage
|
||||||
|
uint16_t BQ27441::voltage(void)
|
||||||
|
{
|
||||||
|
return readWord(BQ27441_COMMAND_VOLTAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads and returns the specified current measurement
|
||||||
|
int16_t BQ27441::current(current_measure type)
|
||||||
|
{
|
||||||
|
int16_t current = 0;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case AVG:
|
||||||
|
current = (int16_t) readWord(BQ27441_COMMAND_AVG_CURRENT);
|
||||||
|
break;
|
||||||
|
case STBY:
|
||||||
|
current = (int16_t) readWord(BQ27441_COMMAND_STDBY_CURRENT);
|
||||||
|
break;
|
||||||
|
case MAX:
|
||||||
|
current = (int16_t) readWord(BQ27441_COMMAND_MAX_CURRENT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads and returns the specified capacity measurement
|
||||||
|
uint16_t BQ27441::capacity(capacity_measure type)
|
||||||
|
{
|
||||||
|
uint16_t capacity = 0;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case REMAIN:
|
||||||
|
return readWord(BQ27441_COMMAND_REM_CAPACITY);
|
||||||
|
break;
|
||||||
|
case FULL:
|
||||||
|
return readWord(BQ27441_COMMAND_FULL_CAPACITY);
|
||||||
|
break;
|
||||||
|
case AVAIL:
|
||||||
|
capacity = readWord(BQ27441_COMMAND_NOM_CAPACITY);
|
||||||
|
break;
|
||||||
|
case AVAIL_FULL:
|
||||||
|
capacity = readWord(BQ27441_COMMAND_AVAIL_CAPACITY);
|
||||||
|
break;
|
||||||
|
case REMAIN_F:
|
||||||
|
capacity = readWord(BQ27441_COMMAND_REM_CAP_FIL);
|
||||||
|
break;
|
||||||
|
case REMAIN_UF:
|
||||||
|
capacity = readWord(BQ27441_COMMAND_REM_CAP_UNFL);
|
||||||
|
break;
|
||||||
|
case FULL_F:
|
||||||
|
capacity = readWord(BQ27441_COMMAND_FULL_CAP_FIL);
|
||||||
|
break;
|
||||||
|
case FULL_UF:
|
||||||
|
capacity = readWord(BQ27441_COMMAND_FULL_CAP_UNFL);
|
||||||
|
break;
|
||||||
|
case DESIGN:
|
||||||
|
capacity = readWord(BQ27441_EXTENDED_CAPACITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads and returns measured average power
|
||||||
|
int16_t BQ27441::power(void)
|
||||||
|
{
|
||||||
|
return (int16_t) readWord(BQ27441_COMMAND_AVG_POWER);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads and returns specified state of charge measurement
|
||||||
|
uint16_t BQ27441::soc(soc_measure type)
|
||||||
|
{
|
||||||
|
uint16_t socRet = 0;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case FILTERED:
|
||||||
|
socRet = readWord(BQ27441_COMMAND_SOC);
|
||||||
|
break;
|
||||||
|
case UNFILTERED:
|
||||||
|
socRet = readWord(BQ27441_COMMAND_SOC_UNFL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return socRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads and returns specified state of health measurement
|
||||||
|
uint8_t BQ27441::soh(soh_measure type)
|
||||||
|
{
|
||||||
|
uint16_t sohRaw = readWord(BQ27441_COMMAND_SOH);
|
||||||
|
uint8_t sohStatus = sohRaw >> 8;
|
||||||
|
uint8_t sohPercent = sohRaw & 0x00FF;
|
||||||
|
|
||||||
|
if (type == PERCENT)
|
||||||
|
return sohPercent;
|
||||||
|
else
|
||||||
|
return sohStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads and returns specified temperature measurement
|
||||||
|
uint16_t BQ27441::temperature(temp_measure type)
|
||||||
|
{
|
||||||
|
uint16_t temp = 0;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BATTERY:
|
||||||
|
temp = readWord(BQ27441_COMMAND_TEMP);
|
||||||
|
break;
|
||||||
|
case INTERNAL_TEMP:
|
||||||
|
temp = readWord(BQ27441_COMMAND_INT_TEMP);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
************************** GPOUT Control Functions **************************
|
||||||
|
*****************************************************************************/
|
||||||
|
// Get GPOUT polarity setting (active-high or active-low)
|
||||||
|
bool BQ27441::GPOUTPolarity(void)
|
||||||
|
{
|
||||||
|
uint16_t opConfigRegister = opConfig();
|
||||||
|
|
||||||
|
return (opConfigRegister & BQ27441_OPCONFIG_GPIOPOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set GPOUT polarity to active-high or active-low
|
||||||
|
bool BQ27441::setGPOUTPolarity(bool activeHigh)
|
||||||
|
{
|
||||||
|
uint16_t oldOpConfig = opConfig();
|
||||||
|
|
||||||
|
// Check to see if we need to update opConfig:
|
||||||
|
if ((activeHigh && (oldOpConfig & BQ27441_OPCONFIG_GPIOPOL)) ||
|
||||||
|
(!activeHigh && !(oldOpConfig & BQ27441_OPCONFIG_GPIOPOL)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
uint16_t newOpConfig = oldOpConfig;
|
||||||
|
if (activeHigh)
|
||||||
|
newOpConfig |= BQ27441_OPCONFIG_GPIOPOL;
|
||||||
|
else
|
||||||
|
newOpConfig &= ~(BQ27441_OPCONFIG_GPIOPOL);
|
||||||
|
|
||||||
|
return writeOpConfig(newOpConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get GPOUT function (BAT_LOW or SOC_INT)
|
||||||
|
bool BQ27441::GPOUTFunction(void)
|
||||||
|
{
|
||||||
|
uint16_t opConfigRegister = opConfig();
|
||||||
|
|
||||||
|
return (opConfigRegister & BQ27441_OPCONFIG_BATLOWEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set GPOUT function to BAT_LOW or SOC_INT
|
||||||
|
bool BQ27441::setGPOUTFunction(gpout_function function)
|
||||||
|
{
|
||||||
|
uint16_t oldOpConfig = opConfig();
|
||||||
|
|
||||||
|
// Check to see if we need to update opConfig:
|
||||||
|
if ((function && (oldOpConfig & BQ27441_OPCONFIG_BATLOWEN)) ||
|
||||||
|
(!function && !(oldOpConfig & BQ27441_OPCONFIG_BATLOWEN)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Modify BATLOWN_EN bit of opConfig:
|
||||||
|
uint16_t newOpConfig = oldOpConfig;
|
||||||
|
if (function)
|
||||||
|
newOpConfig |= BQ27441_OPCONFIG_BATLOWEN;
|
||||||
|
else
|
||||||
|
newOpConfig &= ~(BQ27441_OPCONFIG_BATLOWEN);
|
||||||
|
|
||||||
|
// Write new opConfig
|
||||||
|
return writeOpConfig(newOpConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get SOC1_Set Threshold - threshold to set the alert flag
|
||||||
|
uint8_t BQ27441::SOC1SetThreshold(void)
|
||||||
|
{
|
||||||
|
return readExtendedData(BQ27441_ID_DISCHARGE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get SOC1_Clear Threshold - threshold to clear the alert flag
|
||||||
|
uint8_t BQ27441::SOC1ClearThreshold(void)
|
||||||
|
{
|
||||||
|
return readExtendedData(BQ27441_ID_DISCHARGE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the SOC1 set and clear thresholds to a percentage
|
||||||
|
bool BQ27441::setSOC1Thresholds(uint8_t set, uint8_t clear)
|
||||||
|
{
|
||||||
|
uint8_t thresholds[2];
|
||||||
|
thresholds[0] = constrain(set, 0, 100);
|
||||||
|
thresholds[1] = constrain(clear, 0, 100);
|
||||||
|
return writeExtendedData(BQ27441_ID_DISCHARGE, 0, thresholds, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get SOCF_Set Threshold - threshold to set the alert flag
|
||||||
|
uint8_t BQ27441::SOCFSetThreshold(void)
|
||||||
|
{
|
||||||
|
return readExtendedData(BQ27441_ID_DISCHARGE, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get SOCF_Clear Threshold - threshold to clear the alert flag
|
||||||
|
uint8_t BQ27441::SOCFClearThreshold(void)
|
||||||
|
{
|
||||||
|
return readExtendedData(BQ27441_ID_DISCHARGE, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the SOCF set and clear thresholds to a percentage
|
||||||
|
bool BQ27441::setSOCFThresholds(uint8_t set, uint8_t clear)
|
||||||
|
{
|
||||||
|
uint8_t thresholds[2];
|
||||||
|
thresholds[0] = constrain(set, 0, 100);
|
||||||
|
thresholds[1] = constrain(clear, 0, 100);
|
||||||
|
return writeExtendedData(BQ27441_ID_DISCHARGE, 2, thresholds, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the SOC1 flag is set
|
||||||
|
bool BQ27441::socFlag(void)
|
||||||
|
{
|
||||||
|
uint16_t flagState = flags();
|
||||||
|
|
||||||
|
return flagState & BQ27441_FLAG_SOC1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the SOCF flag is set
|
||||||
|
bool BQ27441::socfFlag(void)
|
||||||
|
{
|
||||||
|
uint16_t flagState = flags();
|
||||||
|
|
||||||
|
return flagState & BQ27441_FLAG_SOCF;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the ITPOR flag is set
|
||||||
|
bool BQ27441::itporFlag(void)
|
||||||
|
{
|
||||||
|
uint16_t flagState = flags();
|
||||||
|
|
||||||
|
return flagState & BQ27441_FLAG_ITPOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the FC flag is set
|
||||||
|
bool BQ27441::fcFlag(void)
|
||||||
|
{
|
||||||
|
uint16_t flagState = flags();
|
||||||
|
|
||||||
|
return flagState & BQ27441_FLAG_FC;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the CHG flag is set
|
||||||
|
bool BQ27441::chgFlag(void)
|
||||||
|
{
|
||||||
|
uint16_t flagState = flags();
|
||||||
|
|
||||||
|
return flagState & BQ27441_FLAG_CHG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the DSG flag is set
|
||||||
|
bool BQ27441::dsgFlag(void)
|
||||||
|
{
|
||||||
|
uint16_t flagState = flags();
|
||||||
|
|
||||||
|
return flagState & BQ27441_FLAG_DSG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the SOC_INT interval delta
|
||||||
|
uint8_t BQ27441::sociDelta(void)
|
||||||
|
{
|
||||||
|
return readExtendedData(BQ27441_ID_STATE, 26);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the SOC_INT interval delta to a value between 1 and 100
|
||||||
|
bool BQ27441::setSOCIDelta(uint8_t delta)
|
||||||
|
{
|
||||||
|
uint8_t soci = constrain(delta, 0, 100);
|
||||||
|
return writeExtendedData(BQ27441_ID_STATE, 26, &soci, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pulse the GPOUT pin - must be in SOC_INT mode
|
||||||
|
bool BQ27441::pulseGPOUT(void)
|
||||||
|
{
|
||||||
|
return executeControlWord(BQ27441_CONTROL_PULSE_SOC_INT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
*************************** Control Sub-Commands ****************************
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
// Read the device type - should be 0x0421
|
||||||
|
uint16_t BQ27441::deviceType(void)
|
||||||
|
{
|
||||||
|
return readControlWord(BQ27441_CONTROL_DEVICE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enter configuration mode - set userControl if calling from an Arduino sketch
|
||||||
|
// and you want control over when to exitConfig
|
||||||
|
bool BQ27441::enterConfig(bool userControl)
|
||||||
|
{
|
||||||
|
if (userControl) _userConfigControl = true;
|
||||||
|
|
||||||
|
if (sealed())
|
||||||
|
{
|
||||||
|
_sealFlag = true;
|
||||||
|
unseal(); // Must be unsealed before making changes
|
||||||
|
}
|
||||||
|
|
||||||
|
if (executeControlWord(BQ27441_CONTROL_SET_CFGUPDATE))
|
||||||
|
{
|
||||||
|
int16_t timeout = BQ72441_I2C_TIMEOUT;
|
||||||
|
while ((timeout--) && (!(flags() & BQ27441_FLAG_CFGUPMODE)))
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
|
||||||
|
if (timeout > 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exit configuration mode with the option to perform a resimulation
|
||||||
|
bool BQ27441::exitConfig(bool resim)
|
||||||
|
{
|
||||||
|
// There are two methods for exiting config mode:
|
||||||
|
// 1. Execute the EXIT_CFGUPDATE command
|
||||||
|
// 2. Execute the SOFT_RESET command
|
||||||
|
// EXIT_CFGUPDATE exits config mode _without_ an OCV (open-circuit voltage)
|
||||||
|
// measurement, and without resimulating to update unfiltered-SoC and SoC.
|
||||||
|
// If a new OCV measurement or resimulation is desired, SOFT_RESET or
|
||||||
|
// EXIT_RESIM should be used to exit config mode.
|
||||||
|
if (resim)
|
||||||
|
{
|
||||||
|
if (softReset())
|
||||||
|
{
|
||||||
|
int16_t timeout = BQ72441_I2C_TIMEOUT;
|
||||||
|
while ((timeout--) && ((flags() & BQ27441_FLAG_CFGUPMODE)))
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
if (timeout > 0)
|
||||||
|
{
|
||||||
|
if (_sealFlag) seal(); // Seal back up if we IC was sealed coming in
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return executeControlWord(BQ27441_CONTROL_EXIT_CFGUPDATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the flags() command
|
||||||
|
uint16_t BQ27441::flags(void)
|
||||||
|
{
|
||||||
|
return readWord(BQ27441_COMMAND_FLAGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the CONTROL_STATUS subcommand of control()
|
||||||
|
uint16_t BQ27441::status(void)
|
||||||
|
{
|
||||||
|
return readControlWord(BQ27441_CONTROL_STATUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************** Private Functions *****************************/
|
||||||
|
|
||||||
|
// Check if the BQ27441-G1A is sealed or not.
|
||||||
|
bool BQ27441::sealed(void)
|
||||||
|
{
|
||||||
|
uint16_t stat = status();
|
||||||
|
return stat & BQ27441_STATUS_SS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seal the BQ27441-G1A
|
||||||
|
bool BQ27441::seal(void)
|
||||||
|
{
|
||||||
|
return readControlWord(BQ27441_CONTROL_SEALED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UNseal the BQ27441-G1A
|
||||||
|
bool BQ27441::unseal(void)
|
||||||
|
{
|
||||||
|
// To unseal the BQ27441, write the key to the control
|
||||||
|
// command. Then immediately write the same key to control again.
|
||||||
|
if (readControlWord(BQ27441_UNSEAL_KEY))
|
||||||
|
{
|
||||||
|
return readControlWord(BQ27441_UNSEAL_KEY);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the 16-bit opConfig register from extended data
|
||||||
|
uint16_t BQ27441::opConfig(void)
|
||||||
|
{
|
||||||
|
return readWord(BQ27441_EXTENDED_OPCONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the 16-bit opConfig register in extended data
|
||||||
|
bool BQ27441::writeOpConfig(uint16_t value)
|
||||||
|
{
|
||||||
|
uint8_t opConfigMSB = value >> 8;
|
||||||
|
uint8_t opConfigLSB = value & 0x00FF;
|
||||||
|
uint8_t opConfigData[2] = {opConfigMSB, opConfigLSB};
|
||||||
|
|
||||||
|
// OpConfig register location: BQ27441_ID_REGISTERS id, offset 0
|
||||||
|
return writeExtendedData(BQ27441_ID_REGISTERS, 0, opConfigData, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue a soft-reset to the BQ27441-G1A
|
||||||
|
bool BQ27441::softReset(void)
|
||||||
|
{
|
||||||
|
return executeControlWord(BQ27441_CONTROL_SOFT_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read a 16-bit command word from the BQ27441-G1A
|
||||||
|
uint16_t BQ27441::readWord(uint16_t subAddress)
|
||||||
|
{
|
||||||
|
uint8_t data[2];
|
||||||
|
i2cReadBytes(subAddress, data, 2);
|
||||||
|
return ((uint16_t) data[1] << 8) | data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read a 16-bit subcommand() from the BQ27441-G1A's control()
|
||||||
|
uint16_t BQ27441::readControlWord(uint16_t function)
|
||||||
|
{
|
||||||
|
uint8_t subCommandMSB = (function >> 8);
|
||||||
|
uint8_t subCommandLSB = (function & 0x00FF);
|
||||||
|
uint8_t command[3] = {0, subCommandLSB, subCommandMSB};
|
||||||
|
uint8_t data[2] = {0, 0};
|
||||||
|
|
||||||
|
i2cWriteBytes((uint8_t) 0, command, 2);
|
||||||
|
|
||||||
|
if (i2cReadBytes((uint8_t) 0, data, 2))
|
||||||
|
{
|
||||||
|
return ((uint16_t)data[1] << 8) | data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute a subcommand() from the BQ27441-G1A's control()
|
||||||
|
bool BQ27441::executeControlWord(uint16_t function)
|
||||||
|
{
|
||||||
|
uint8_t subCommandMSB = (function >> 8);
|
||||||
|
uint8_t subCommandLSB = (function & 0x00FF);
|
||||||
|
uint8_t command[2] = {subCommandLSB, subCommandMSB};
|
||||||
|
|
||||||
|
if (i2cWriteBytes((uint8_t) 0, command, 2))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
************************** Extended Data Commands ***************************
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
// Issue a BlockDataControl() command to enable BlockData access
|
||||||
|
bool BQ27441::blockDataControl(void)
|
||||||
|
{
|
||||||
|
uint8_t enableByte = 0x00;
|
||||||
|
return i2cWriteBytes(BQ27441_EXTENDED_CONTROL, &enableByte, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue a DataClass() command to set the data class to be accessed
|
||||||
|
bool BQ27441::blockDataClass(uint8_t id)
|
||||||
|
{
|
||||||
|
return i2cWriteBytes(BQ27441_EXTENDED_DATACLASS, &id, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue a DataBlock() command to set the data block to be accessed
|
||||||
|
bool BQ27441::blockDataOffset(uint8_t offset)
|
||||||
|
{
|
||||||
|
return i2cWriteBytes(BQ27441_EXTENDED_DATABLOCK, &offset, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the current checksum using BlockDataCheckSum()
|
||||||
|
uint8_t BQ27441::blockDataChecksum(void)
|
||||||
|
{
|
||||||
|
uint8_t csum;
|
||||||
|
i2cReadBytes(BQ27441_EXTENDED_CHECKSUM, &csum, 1);
|
||||||
|
return csum;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use BlockData() to read a byte from the loaded extended data
|
||||||
|
uint8_t BQ27441::readBlockData(uint8_t offset)
|
||||||
|
{
|
||||||
|
uint8_t ret;
|
||||||
|
uint8_t address = offset + BQ27441_EXTENDED_BLOCKDATA;
|
||||||
|
i2cReadBytes(address, &ret, 1);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use BlockData() to write a byte to an offset of the loaded data
|
||||||
|
bool BQ27441::writeBlockData(uint8_t offset, uint8_t data)
|
||||||
|
{
|
||||||
|
uint8_t address = offset + BQ27441_EXTENDED_BLOCKDATA;
|
||||||
|
return i2cWriteBytes(address, &data, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read all 32 bytes of the loaded extended data and compute a
|
||||||
|
// checksum based on the values.
|
||||||
|
uint8_t BQ27441::computeBlockChecksum(void)
|
||||||
|
{
|
||||||
|
uint8_t data[32];
|
||||||
|
i2cReadBytes(BQ27441_EXTENDED_BLOCKDATA, data, 32);
|
||||||
|
|
||||||
|
uint8_t csum = 0;
|
||||||
|
for (int i=0; i<32; i++)
|
||||||
|
{
|
||||||
|
csum += data[i];
|
||||||
|
}
|
||||||
|
csum = 255 - csum;
|
||||||
|
|
||||||
|
return csum;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the BlockDataCheckSum() command to write a checksum value
|
||||||
|
bool BQ27441::writeBlockChecksum(uint8_t csum)
|
||||||
|
{
|
||||||
|
return i2cWriteBytes(BQ27441_EXTENDED_CHECKSUM, &csum, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read a byte from extended data specifying a class ID and position offset
|
||||||
|
uint8_t BQ27441::readExtendedData(uint8_t classID, uint8_t offset)
|
||||||
|
{
|
||||||
|
uint8_t retData = 0;
|
||||||
|
if (!_userConfigControl) enterConfig(false);
|
||||||
|
|
||||||
|
if (!blockDataControl()) // // enable block data memory control
|
||||||
|
return false; // Return false if enable fails
|
||||||
|
if (!blockDataClass(classID)) // Write class ID using DataBlockClass()
|
||||||
|
return false;
|
||||||
|
|
||||||
|
blockDataOffset(offset / 32); // Write 32-bit block offset (usually 0)
|
||||||
|
|
||||||
|
computeBlockChecksum(); // Compute checksum going in
|
||||||
|
retData = readBlockData(offset % 32); // Read from offset (limit to 0-31)
|
||||||
|
|
||||||
|
if (!_userConfigControl) exitConfig();
|
||||||
|
|
||||||
|
return retData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write a specified number of bytes to extended data specifying a
|
||||||
|
// class ID, position offset.
|
||||||
|
bool BQ27441::writeExtendedData(uint8_t classID, uint8_t offset, uint8_t * data, uint8_t len)
|
||||||
|
{
|
||||||
|
if (len > 32)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!_userConfigControl) enterConfig(false);
|
||||||
|
|
||||||
|
if (!blockDataControl()) // // enable block data memory control
|
||||||
|
return false; // Return false if enable fails
|
||||||
|
if (!blockDataClass(classID)) // Write class ID using DataBlockClass()
|
||||||
|
return false;
|
||||||
|
|
||||||
|
blockDataOffset(offset / 32); // Write 32-bit block offset (usually 0)
|
||||||
|
computeBlockChecksum(); // Compute checksum going in
|
||||||
|
|
||||||
|
// Write data bytes:
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
// Write to offset, mod 32 if offset is greater than 32
|
||||||
|
// The blockDataOffset above sets the 32-bit block
|
||||||
|
writeBlockData((offset % 32) + i, data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write new checksum using BlockDataChecksum (0x60)
|
||||||
|
uint8_t newCsum = computeBlockChecksum(); // Compute the new checksum
|
||||||
|
writeBlockChecksum(newCsum);
|
||||||
|
|
||||||
|
if (!_userConfigControl) exitConfig();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
************************ I2C Read and Write Routines ************************
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
// Read a specified number of bytes over I2C at a given subAddress
|
||||||
|
int16_t BQ27441::i2cReadBytes(uint8_t subAddress, uint8_t * dest, uint8_t count)
|
||||||
|
{
|
||||||
|
int16_t timeout = BQ72441_I2C_TIMEOUT;
|
||||||
|
i2c_master_write_read_device(BQ72441_I2C_NUM, _deviceAddress, &subAddress, 1, dest, count, timeout);
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write a specified number of bytes over I2C to a given subAddress
|
||||||
|
uint16_t BQ27441::i2cWriteBytes(uint8_t subAddress, uint8_t * src, uint8_t count)
|
||||||
|
{
|
||||||
|
int16_t timeout = BQ72441_I2C_TIMEOUT;
|
||||||
|
|
||||||
|
// prepend the subAddress to the data.
|
||||||
|
uint8_t w_buff[count+1] = {0};
|
||||||
|
w_buff[0] = subAddress;
|
||||||
|
for (int i = 0; i < count; i ++) {
|
||||||
|
w_buff[i+1] = src[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t ret = i2c_master_write_to_device(BQ72441_I2C_NUM, _deviceAddress, src, count+1, timeout);
|
||||||
|
|
||||||
|
return ret == ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
BQ27441 lipo;
|
||||||
@@ -0,0 +1,564 @@
|
|||||||
|
// Modified or adapted from https://github.com/sparkfun/SparkFun_BQ27441_Arduino_Library
|
||||||
|
//
|
||||||
|
// Originally Licensed under the MIT
|
||||||
|
/*
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 SparkFun Electronics, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
/******************************************************************************
|
||||||
|
SparkFunBQ27441.h
|
||||||
|
BQ27441 Arduino Library Main Header File
|
||||||
|
Jim Lindblom @ SparkFun Electronics
|
||||||
|
May 9, 2016
|
||||||
|
https://github.com/sparkfun/SparkFun_BQ27441_Arduino_Library
|
||||||
|
|
||||||
|
Definition of the BQ27441 library, which implements all features of the
|
||||||
|
BQ27441 LiPo Fuel Gauge.
|
||||||
|
|
||||||
|
Hardware Resources:
|
||||||
|
- Arduino Development Board
|
||||||
|
- SparkFun Battery Babysitter
|
||||||
|
|
||||||
|
Development environment specifics:
|
||||||
|
Arduino 1.6.7
|
||||||
|
SparkFun Battery Babysitter v1.0
|
||||||
|
Arduino Uno (any 'duino should do)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SparkFunBQ27441_h
|
||||||
|
#define SparkFunBQ27441_h
|
||||||
|
|
||||||
|
#include "BQ27441_Definitions.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "driver/i2c.h"
|
||||||
|
|
||||||
|
#define BQ72441_I2C_NUM I2C_NUM_0
|
||||||
|
|
||||||
|
#define BQ72441_I2C_TIMEOUT 2000
|
||||||
|
|
||||||
|
// Parameters for the current() function, to specify which current to read
|
||||||
|
typedef enum {
|
||||||
|
AVG, // Average Current (DEFAULT)
|
||||||
|
STBY, // Standby Current
|
||||||
|
MAX // Max Current
|
||||||
|
} current_measure;
|
||||||
|
|
||||||
|
// Parameters for the capacity() function, to specify which capacity to read
|
||||||
|
typedef enum {
|
||||||
|
REMAIN, // Remaining Capacity (DEFAULT)
|
||||||
|
FULL, // Full Capacity
|
||||||
|
AVAIL, // Available Capacity
|
||||||
|
AVAIL_FULL, // Full Available Capacity
|
||||||
|
REMAIN_F, // Remaining Capacity Filtered
|
||||||
|
REMAIN_UF, // Remaining Capacity Unfiltered
|
||||||
|
FULL_F, // Full Capacity Filtered
|
||||||
|
FULL_UF, // Full Capacity Unfiltered
|
||||||
|
DESIGN // Design Capacity
|
||||||
|
} capacity_measure;
|
||||||
|
|
||||||
|
// Parameters for the soc() function
|
||||||
|
typedef enum {
|
||||||
|
FILTERED, // State of Charge Filtered (DEFAULT)
|
||||||
|
UNFILTERED // State of Charge Unfiltered
|
||||||
|
} soc_measure;
|
||||||
|
|
||||||
|
// Parameters for the soh() function
|
||||||
|
typedef enum {
|
||||||
|
PERCENT, // State of Health Percentage (DEFAULT)
|
||||||
|
SOH_STAT // State of Health Status Bits
|
||||||
|
} soh_measure;
|
||||||
|
|
||||||
|
// Parameters for the temperature() function
|
||||||
|
typedef enum {
|
||||||
|
BATTERY, // Battery Temperature (DEFAULT)
|
||||||
|
INTERNAL_TEMP // Internal IC Temperature
|
||||||
|
} temp_measure;
|
||||||
|
|
||||||
|
// Parameters for the setGPOUTFunction() funciton
|
||||||
|
typedef enum {
|
||||||
|
SOC_INT, // Set GPOUT to SOC_INT functionality
|
||||||
|
BAT_LOW // Set GPOUT to BAT_LOW functionality
|
||||||
|
} gpout_function;
|
||||||
|
|
||||||
|
class BQ27441 {
|
||||||
|
public:
|
||||||
|
//////////////////////////////
|
||||||
|
// Initialization Functions //
|
||||||
|
//////////////////////////////
|
||||||
|
/**
|
||||||
|
Initializes class variables
|
||||||
|
*/
|
||||||
|
BQ27441();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes I2C and verifies communication with the BQ27441.
|
||||||
|
Must be called before using any other functions.
|
||||||
|
|
||||||
|
@return true if communication was successful.
|
||||||
|
*/
|
||||||
|
bool begin(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Configures the design capacity of the connected battery.
|
||||||
|
|
||||||
|
@param capacity of battery (unsigned 16-bit value)
|
||||||
|
@return true if capacity successfully set.
|
||||||
|
*/
|
||||||
|
bool setCapacity(uint16_t capacity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Configures the design energy of the connected battery.
|
||||||
|
|
||||||
|
@param energy of battery (unsigned 16-bit value)
|
||||||
|
@return true if energy successfully set.
|
||||||
|
*/
|
||||||
|
bool setDesignEnergy(uint16_t energy);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Configures terminate voltage (lowest operational voltage of battery powered circuit)
|
||||||
|
|
||||||
|
@param voltage of battery (unsigned 16-bit value)
|
||||||
|
@return true if energy successfully set.
|
||||||
|
*/
|
||||||
|
bool setTerminateVoltage(uint16_t voltage);
|
||||||
|
|
||||||
|
bool setTaperRate(uint16_t rate);
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// Battery Characteristics //
|
||||||
|
/////////////////////////////
|
||||||
|
/**
|
||||||
|
Reads and returns the battery voltage
|
||||||
|
|
||||||
|
@return battery voltage in mV
|
||||||
|
*/
|
||||||
|
uint16_t voltage(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads and returns the specified current measurement
|
||||||
|
|
||||||
|
@param current_measure enum specifying current value to be read
|
||||||
|
@return specified current measurement in mA. >0 indicates charging.
|
||||||
|
*/
|
||||||
|
int16_t current(current_measure type = AVG);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads and returns the specified capacity measurement
|
||||||
|
|
||||||
|
@param capacity_measure enum specifying capacity value to be read
|
||||||
|
@return specified capacity measurement in mAh.
|
||||||
|
*/
|
||||||
|
uint16_t capacity(capacity_measure type = REMAIN);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads and returns measured average power
|
||||||
|
|
||||||
|
@return average power in mAh. >0 indicates charging.
|
||||||
|
*/
|
||||||
|
int16_t power(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads and returns specified state of charge measurement
|
||||||
|
|
||||||
|
@param soc_measure enum specifying filtered or unfiltered measurement
|
||||||
|
@return specified state of charge measurement in %
|
||||||
|
*/
|
||||||
|
uint16_t soc(soc_measure type = FILTERED);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads and returns specified state of health measurement
|
||||||
|
|
||||||
|
@param soh_measure enum specifying filtered or unfiltered measurement
|
||||||
|
@return specified state of health measurement in %, or status bits
|
||||||
|
*/
|
||||||
|
uint8_t soh(soh_measure type = PERCENT);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads and returns specified temperature measurement
|
||||||
|
|
||||||
|
@param temp_measure enum specifying internal or battery measurement
|
||||||
|
@return specified temperature measurement in degrees C
|
||||||
|
*/
|
||||||
|
uint16_t temperature(temp_measure type = BATTERY);
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// GPOUT Control Commands //
|
||||||
|
////////////////////////////
|
||||||
|
/**
|
||||||
|
Get GPOUT polarity setting (active-high or active-low)
|
||||||
|
|
||||||
|
@return true if active-high, false if active-low
|
||||||
|
*/
|
||||||
|
bool GPOUTPolarity(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set GPOUT polarity to active-high or active-low
|
||||||
|
|
||||||
|
@param activeHigh is true if active-high, false if active-low
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool setGPOUTPolarity(bool activeHigh);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get GPOUT function (BAT_LOW or SOC_INT)
|
||||||
|
|
||||||
|
@return true if BAT_LOW or false if SOC_INT
|
||||||
|
*/
|
||||||
|
bool GPOUTFunction(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set GPOUT function to BAT_LOW or SOC_INT
|
||||||
|
|
||||||
|
@param function should be either BAT_LOW or SOC_INT
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool setGPOUTFunction(gpout_function function);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get SOC1_Set Threshold - threshold to set the alert flag
|
||||||
|
|
||||||
|
@return state of charge value between 0 and 100%
|
||||||
|
*/
|
||||||
|
uint8_t SOC1SetThreshold(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get SOC1_Clear Threshold - threshold to clear the alert flag
|
||||||
|
|
||||||
|
@return state of charge value between 0 and 100%
|
||||||
|
*/
|
||||||
|
uint8_t SOC1ClearThreshold(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the SOC1 set and clear thresholds to a percentage
|
||||||
|
|
||||||
|
@param set and clear percentages between 0 and 100. clear > set.
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool setSOC1Thresholds(uint8_t set, uint8_t clear);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get SOCF_Set Threshold - threshold to set the alert flag
|
||||||
|
|
||||||
|
@return state of charge value between 0 and 100%
|
||||||
|
*/
|
||||||
|
uint8_t SOCFSetThreshold(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get SOCF_Clear Threshold - threshold to clear the alert flag
|
||||||
|
|
||||||
|
@return state of charge value between 0 and 100%
|
||||||
|
*/
|
||||||
|
uint8_t SOCFClearThreshold(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the SOCF set and clear thresholds to a percentage
|
||||||
|
|
||||||
|
@param set and clear percentages between 0 and 100. clear > set.
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool setSOCFThresholds(uint8_t set, uint8_t clear);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the SOC1 flag is set in flags()
|
||||||
|
|
||||||
|
@return true if flag is set
|
||||||
|
*/
|
||||||
|
bool socFlag(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the SOCF flag is set in flags()
|
||||||
|
|
||||||
|
@return true if flag is set
|
||||||
|
*/
|
||||||
|
bool socfFlag(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the ITPOR flag is set in flags()
|
||||||
|
|
||||||
|
@return true if flag is set
|
||||||
|
*/
|
||||||
|
bool itporFlag(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the FC flag is set in flags()
|
||||||
|
|
||||||
|
@return true if flag is set
|
||||||
|
*/
|
||||||
|
bool fcFlag(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the CHG flag is set in flags()
|
||||||
|
|
||||||
|
@return true if flag is set
|
||||||
|
*/
|
||||||
|
bool chgFlag(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the DSG flag is set in flags()
|
||||||
|
|
||||||
|
@return true if flag is set
|
||||||
|
*/
|
||||||
|
bool dsgFlag(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the SOC_INT interval delta
|
||||||
|
|
||||||
|
@return interval percentage value between 1 and 100
|
||||||
|
*/
|
||||||
|
uint8_t sociDelta(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the SOC_INT interval delta to a value between 1 and 100
|
||||||
|
|
||||||
|
@param interval percentage value between 1 and 100
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool setSOCIDelta(uint8_t delta);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Pulse the GPOUT pin - must be in SOC_INT mode
|
||||||
|
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool pulseGPOUT(void);
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
// Control Sub-commands //
|
||||||
|
//////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read the device type - should be 0x0421
|
||||||
|
|
||||||
|
@return 16-bit value read from DEVICE_TYPE subcommand
|
||||||
|
*/
|
||||||
|
uint16_t deviceType(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Enter configuration mode - set userControl if calling from an Arduino
|
||||||
|
sketch and you want control over when to exitConfig.
|
||||||
|
|
||||||
|
@param userControl is true if the Arduino sketch is handling entering
|
||||||
|
and exiting config mode (should be false in library calls).
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool enterConfig(bool userControl = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Exit configuration mode with the option to perform a resimulation
|
||||||
|
|
||||||
|
@param resim is true if resimulation should be performed after exiting
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool exitConfig(bool resim = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read the flags() command
|
||||||
|
|
||||||
|
@return 16-bit representation of flags() command register
|
||||||
|
*/
|
||||||
|
uint16_t flags(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read the CONTROL_STATUS subcommand of control()
|
||||||
|
|
||||||
|
@return 16-bit representation of CONTROL_STATUS subcommand
|
||||||
|
*/
|
||||||
|
uint16_t status(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t _deviceAddress; // Stores the BQ27441-G1A's I2C address
|
||||||
|
bool _sealFlag; // Global to identify that IC was previously sealed
|
||||||
|
bool _userConfigControl; // Global to identify that user has control over
|
||||||
|
// entering/exiting config
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the BQ27441-G1A is sealed or not.
|
||||||
|
|
||||||
|
@return true if the chip is sealed
|
||||||
|
*/
|
||||||
|
bool sealed(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Seal the BQ27441-G1A
|
||||||
|
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool seal(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
UNseal the BQ27441-G1A
|
||||||
|
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool unseal(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read the 16-bit opConfig register from extended data
|
||||||
|
|
||||||
|
@return opConfig register contents
|
||||||
|
*/
|
||||||
|
uint16_t opConfig(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Write the 16-bit opConfig register in extended data
|
||||||
|
|
||||||
|
@param New 16-bit value for opConfig
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool writeOpConfig(uint16_t value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Issue a soft-reset to the BQ27441-G1A
|
||||||
|
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool softReset(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read a 16-bit command word from the BQ27441-G1A
|
||||||
|
|
||||||
|
@param subAddress is the command to be read from
|
||||||
|
@return 16-bit value of the command's contents
|
||||||
|
*/
|
||||||
|
uint16_t readWord(uint16_t subAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read a 16-bit subcommand() from the BQ27441-G1A's control()
|
||||||
|
|
||||||
|
@param function is the subcommand of control() to be read
|
||||||
|
@return 16-bit value of the subcommand's contents
|
||||||
|
*/
|
||||||
|
uint16_t readControlWord(uint16_t function);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Execute a subcommand() from the BQ27441-G1A's control()
|
||||||
|
|
||||||
|
@param function is the subcommand of control() to be executed
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool executeControlWord(uint16_t function);
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// Extended Data Commands //
|
||||||
|
////////////////////////////
|
||||||
|
/**
|
||||||
|
Issue a BlockDataControl() command to enable BlockData access
|
||||||
|
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool blockDataControl(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Issue a DataClass() command to set the data class to be accessed
|
||||||
|
|
||||||
|
@param id is the id number of the class
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool blockDataClass(uint8_t id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Issue a DataBlock() command to set the data block to be accessed
|
||||||
|
|
||||||
|
@param offset of the data block
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool blockDataOffset(uint8_t offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read the current checksum using BlockDataCheckSum()
|
||||||
|
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
uint8_t blockDataChecksum(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Use BlockData() to read a byte from the loaded extended data
|
||||||
|
|
||||||
|
@param offset of data block byte to be read
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
uint8_t readBlockData(uint8_t offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Use BlockData() to write a byte to an offset of the loaded data
|
||||||
|
|
||||||
|
@param offset is the position of the byte to be written
|
||||||
|
data is the value to be written
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool writeBlockData(uint8_t offset, uint8_t data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read all 32 bytes of the loaded extended data and compute a
|
||||||
|
checksum based on the values.
|
||||||
|
|
||||||
|
@return 8-bit checksum value calculated based on loaded data
|
||||||
|
*/
|
||||||
|
uint8_t computeBlockChecksum(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Use the BlockDataCheckSum() command to write a checksum value
|
||||||
|
|
||||||
|
@param csum is the 8-bit checksum to be written
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool writeBlockChecksum(uint8_t csum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read a byte from extended data specifying a class ID and position offset
|
||||||
|
|
||||||
|
@param classID is the id of the class to be read from
|
||||||
|
offset is the byte position of the byte to be read
|
||||||
|
@return 8-bit value of specified data
|
||||||
|
*/
|
||||||
|
uint8_t readExtendedData(uint8_t classID, uint8_t offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Write a specified number of bytes to extended data specifying a
|
||||||
|
class ID, position offset.
|
||||||
|
|
||||||
|
@param classID is the id of the class to be read from
|
||||||
|
offset is the byte position of the byte to be read
|
||||||
|
data is the data buffer to be written
|
||||||
|
len is the number of bytes to be written
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
bool writeExtendedData(uint8_t classID, uint8_t offset, uint8_t * data, uint8_t len);
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// I2C Read and Write Routines //
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read a specified number of bytes over I2C at a given subAddress
|
||||||
|
|
||||||
|
@param subAddress is the 8-bit address of the data to be read
|
||||||
|
dest is the data buffer to be written to
|
||||||
|
count is the number of bytes to be read
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
int16_t i2cReadBytes(uint8_t subAddress, uint8_t * dest, uint8_t count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Write a specified number of bytes over I2C to a given subAddress
|
||||||
|
|
||||||
|
@param subAddress is the 8-bit address of the data to be written to
|
||||||
|
src is the data buffer to be written
|
||||||
|
count is the number of bytes to be written
|
||||||
|
@return true on success
|
||||||
|
*/
|
||||||
|
uint16_t i2cWriteBytes(uint8_t subAddress, uint8_t * src, uint8_t count);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern BQ27441 lipo; // Use lipo.[] to interact with the library in an Arduino sketch
|
||||||
|
// Thanks for reading!
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#include "all.h"
|
||||||
|
|
||||||
|
static const char *TAG = "driver_all";
|
||||||
|
static void init_i2c();
|
||||||
|
|
||||||
|
void init_drivers() {
|
||||||
|
init_i2c();
|
||||||
|
// init char_lcd so we can use it to report other initialization errors.
|
||||||
|
init_lcd();
|
||||||
|
// init the bottom half so that we can get user input.
|
||||||
|
init_bottom_half();
|
||||||
|
init_sd();
|
||||||
|
init_speaker();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Initializes I2C_NUM_0.
|
||||||
|
///
|
||||||
|
/// This is hooked up the to:
|
||||||
|
/// - The bottom half
|
||||||
|
/// - The char lcd
|
||||||
|
/// - The power board
|
||||||
|
/// - The MPU6050
|
||||||
|
/// - The PERH port
|
||||||
|
/// - The Capacitive Touch Panel
|
||||||
|
static void init_i2c() {
|
||||||
|
ESP_LOGI(TAG, "Initializing i2c...");
|
||||||
|
|
||||||
|
i2c_config_t conf = {
|
||||||
|
.mode = I2C_MODE_MASTER,
|
||||||
|
.sda_io_num = GPIO_NUM_5,
|
||||||
|
.scl_io_num = GPIO_NUM_6,
|
||||||
|
.sda_pullup_en = GPIO_PULLUP_DISABLE,
|
||||||
|
.scl_pullup_en = GPIO_PULLUP_DISABLE,
|
||||||
|
// .sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
// .scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
.master = {
|
||||||
|
.clk_speed = 100*1000,
|
||||||
|
},
|
||||||
|
.clk_flags = I2C_SCLK_SRC_FLAG_FOR_NOMAL
|
||||||
|
};
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &conf));
|
||||||
|
ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, conf.mode, 0, 0, 0));
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "i2c initialized!");
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef ALL_H
|
||||||
|
#define ALL_H
|
||||||
|
|
||||||
|
// #include "driver/uart.h"
|
||||||
|
// #include "driver/i2c.h"
|
||||||
|
// #include "drivers/tft.h"
|
||||||
|
// #include "drivers/wires.h"
|
||||||
|
// #include "drivers/sd.h"
|
||||||
|
// #include "drivers/game_timer.h"
|
||||||
|
// #include "drivers/speaker.h"
|
||||||
|
// #include "drivers/char_lcd.h"
|
||||||
|
// #include "drivers/leds.h"
|
||||||
|
// #include "drivers/power.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "char_lcd.h"
|
||||||
|
#include "drivers/bottom_half.h"
|
||||||
|
#include "sd.h"
|
||||||
|
|
||||||
|
void init_drivers();
|
||||||
|
|
||||||
|
#endif /* ALL_H */
|
||||||
+176
-141
@@ -3,27 +3,162 @@
|
|||||||
static const char *TAG = "bottom_half";
|
static const char *TAG = "bottom_half";
|
||||||
|
|
||||||
static uint16_t keypad_state;
|
static uint16_t keypad_state;
|
||||||
static uint16_t button_state;
|
static uint8_t button_state;
|
||||||
|
static uint8_t switch_state;
|
||||||
|
static uint8_t switch_touch_state;
|
||||||
static uint8_t touch_state;
|
static uint8_t touch_state;
|
||||||
|
|
||||||
static uint16_t keypad_pressed;
|
static uint16_t keypad_pressed;
|
||||||
static uint16_t button_pressed;
|
static uint8_t button_pressed;
|
||||||
|
static uint8_t switch_flipped_up;
|
||||||
|
static uint8_t switch_touch_pressed;
|
||||||
static uint8_t touch_pressed;
|
static uint8_t touch_pressed;
|
||||||
|
|
||||||
static uint16_t keypad_released;
|
static uint16_t keypad_released;
|
||||||
static uint16_t button_released;
|
static uint8_t button_released;
|
||||||
|
static uint8_t switch_flipped_down;
|
||||||
|
static uint8_t switch_touch_released;
|
||||||
static uint8_t touch_released;
|
static uint8_t touch_released;
|
||||||
|
|
||||||
/// read buffer
|
/// read buffer
|
||||||
static uint8_t buf[8];
|
static uint8_t buf[8];
|
||||||
|
|
||||||
|
static void poll_bottom_task(void *arg);
|
||||||
|
static void receive_keypad();
|
||||||
|
static void receive_button_switch();
|
||||||
|
static void receive_touch();
|
||||||
|
|
||||||
|
// TODO: add intrupt on bottom half delta pin
|
||||||
|
// static void IRAM_ATTR gpio_isr_handler(void* arg)
|
||||||
|
// {
|
||||||
|
// // TODO: do somthing
|
||||||
|
// ESP_LOGI("BOTTOM_HALF", "Hit");
|
||||||
|
// }
|
||||||
|
|
||||||
|
void init_bottom_half() {
|
||||||
|
ESP_LOGI(TAG, "Initializing bottom half...");
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(gpio_set_direction(BOTTOM_PIN_INTERUPT, GPIO_MODE_INPUT));
|
||||||
|
ESP_ERROR_CHECK(gpio_set_pull_mode(BOTTOM_PIN_INTERUPT, GPIO_PULLUP_ONLY));
|
||||||
|
|
||||||
|
// TODO: do interupt stuff.
|
||||||
|
// ESP_ERROR_CHECK(gpio_intr_enable(BOTTOM_PIN_INTERUPT));
|
||||||
|
// ESP_ERROR_CHECK(gpio_install_isr_service(ESP_INTR_FLAG))
|
||||||
|
//install gpio isr service
|
||||||
|
// gpio_install_isr_service(0);
|
||||||
|
//hook isr handler for specific gpio pin
|
||||||
|
// gpio_isr_handler_add(BOTTOM_INTERUPT_PIN, gpio_isr_handler, NULL);
|
||||||
|
|
||||||
|
receive_keypad();
|
||||||
|
receive_button_switch();
|
||||||
|
receive_touch();
|
||||||
|
|
||||||
|
xTaskCreate(poll_bottom_task, "poll_bottom", 4096, NULL, 10, NULL);
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Bottom half initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t receive_delta(void) {
|
||||||
|
uint8_t reg = 1;
|
||||||
|
buf[0] = 0;
|
||||||
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||||
|
return buf[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void receive_keypad(void) {
|
||||||
|
uint8_t reg = 2;
|
||||||
|
buf[0] = 0;
|
||||||
|
buf[1] = 0;
|
||||||
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 2, (100 / portTICK_PERIOD_MS)));
|
||||||
|
uint16_t new_keypad_state = buf[0] | (buf[1] << 8);
|
||||||
|
|
||||||
|
uint16_t just_pressed = new_keypad_state & ~keypad_state;
|
||||||
|
keypad_pressed |= just_pressed;
|
||||||
|
|
||||||
|
uint16_t just_released = ~new_keypad_state & keypad_state;
|
||||||
|
keypad_released |= just_released;
|
||||||
|
|
||||||
|
keypad_state = new_keypad_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void receive_button_switch(void) {
|
||||||
|
uint8_t reg = 3;
|
||||||
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 2, (100 / portTICK_PERIOD_MS)));
|
||||||
|
uint8_t new_button_state = buf[1] & 0xF;
|
||||||
|
uint8_t new_switch_state = (~buf[0]) & 0xF;
|
||||||
|
uint8_t new_switch_touch_state = (buf[1] >> 4) & 0xF;
|
||||||
|
|
||||||
|
// button
|
||||||
|
uint8_t just_pressed = new_button_state & ~button_state;
|
||||||
|
button_pressed |= just_pressed;
|
||||||
|
|
||||||
|
uint8_t just_released = ~new_button_state & button_state;
|
||||||
|
button_released |= just_released;
|
||||||
|
|
||||||
|
button_state = new_button_state;
|
||||||
|
|
||||||
|
// switch
|
||||||
|
uint8_t just_flipped_up = new_switch_state & ~switch_state;
|
||||||
|
switch_flipped_up |= just_flipped_up;
|
||||||
|
|
||||||
|
uint8_t just_flipped_down = ~new_switch_state & switch_state;
|
||||||
|
switch_flipped_down |= just_flipped_down;
|
||||||
|
|
||||||
|
switch_state = new_switch_state;
|
||||||
|
|
||||||
|
// switch touch
|
||||||
|
uint8_t touch_just_pressed = new_switch_touch_state & ~switch_touch_state;
|
||||||
|
switch_touch_pressed |= touch_just_pressed;
|
||||||
|
|
||||||
|
uint8_t touch_just_released = ~new_switch_touch_state & switch_touch_state;
|
||||||
|
switch_touch_released |= touch_just_released;
|
||||||
|
|
||||||
|
switch_touch_state = new_switch_touch_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void receive_touch(void) {
|
||||||
|
uint8_t reg = 4;
|
||||||
|
buf[0] = 0;
|
||||||
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||||
|
bool new_touch_state = buf[0] != 0;
|
||||||
|
|
||||||
|
bool just_pressed = new_touch_state & !touch_state;
|
||||||
|
touch_pressed |= just_pressed;
|
||||||
|
|
||||||
|
bool just_released = (!new_touch_state) & touch_state;
|
||||||
|
touch_released |= just_released;
|
||||||
|
|
||||||
|
touch_state = new_touch_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void poll_bottom_task(void *arg) {
|
||||||
|
// TODO: if using an interupt, switch this to use a queue
|
||||||
|
while (1) {
|
||||||
|
bool new_data = gpio_get_level(BOTTOM_PIN_INTERUPT) == 0;
|
||||||
|
if (new_data) {
|
||||||
|
uint8_t delta = receive_delta();
|
||||||
|
// ESP_LOGI(_TAG, "delta: %d", delta);
|
||||||
|
if (delta == 0) ESP_LOGW(TAG, "delta pin was low, but delta register returned 0");
|
||||||
|
|
||||||
|
if (delta & (1 << DELTA_BIT_KP)) receive_keypad();
|
||||||
|
if (delta & (1 << DELTA_BIT_BUTTON_SWITCH)) receive_button_switch();
|
||||||
|
if (delta & (1 << DELTA_BIT_TOUCH)) receive_touch();
|
||||||
|
}
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void clear_all_pressed_released(void) {
|
void clear_all_pressed_released(void) {
|
||||||
keypad_pressed = 0;
|
keypad_pressed = 0;
|
||||||
button_pressed = 0;
|
button_pressed = 0;
|
||||||
|
switch_flipped_up = 0;
|
||||||
touch_pressed = 0;
|
touch_pressed = 0;
|
||||||
|
|
||||||
keypad_released = 0;
|
keypad_released = 0;
|
||||||
button_released = 0;
|
button_released = 0;
|
||||||
|
switch_flipped_down = 0;
|
||||||
touch_released = 0;
|
touch_released = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,10 +177,10 @@ static bool _take_key(KeypadKey* kp, uint16_t* keypad_bitfield) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_pressed_keypad(KeypadKey* kp) {
|
bool get_keypad_pressed(KeypadKey* kp) {
|
||||||
return _take_key(kp, &keypad_pressed);
|
return _take_key(kp, &keypad_pressed);
|
||||||
}
|
}
|
||||||
bool get_released_keypad(KeypadKey* kp) {
|
bool get_keypad_released(KeypadKey* kp) {
|
||||||
return _take_key(kp, &keypad_released);
|
return _take_key(kp, &keypad_released);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,9 +223,12 @@ char char_of_keypad_key(KeypadKey kp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _take_button(ButtonKey* button, uint16_t* button_bitfield) {
|
static bool _take_button(ButtonKey* button, uint8_t* button_bitfield) {
|
||||||
|
if (((*button_bitfield) & 0xF) == 0) return false;
|
||||||
|
|
||||||
|
// scan the 4 button bits for one that is set
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int bit_selector = (1 << (i+8));
|
int bit_selector = (1 << i);
|
||||||
if ((*button_bitfield) & bit_selector) {
|
if ((*button_bitfield) & bit_selector) {
|
||||||
if (button != nullptr) {
|
if (button != nullptr) {
|
||||||
*button = (ButtonKey) i;
|
*button = (ButtonKey) i;
|
||||||
@@ -102,42 +240,47 @@ static bool _take_button(ButtonKey* button, uint16_t* button_bitfield) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
static bool _take_switch(SwitchKey* switch_, uint16_t* button_bitfield) {
|
static bool _take_switch(SwitchKey* switch_, uint8_t* switch_bitfield) {
|
||||||
|
if (((*switch_bitfield) & 0xF) == 0) return false;
|
||||||
|
|
||||||
|
// scan the 4 switch bits for one that is set
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int bit_selector = (1 << i);
|
int bit_selector = (1 << i);
|
||||||
if ((*button_bitfield) & bit_selector) {
|
if ((*switch_bitfield) & bit_selector) {
|
||||||
if (switch_ != nullptr) {
|
if (switch_ != nullptr) {
|
||||||
*switch_ = (SwitchKey) i;
|
*switch_ = (SwitchKey) i;
|
||||||
}
|
}
|
||||||
// clear bit
|
// clear bit
|
||||||
*button_bitfield &= ~bit_selector;
|
*switch_bitfield &= ~bit_selector;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_pressed_button(ButtonKey* button) {
|
bool get_button_pressed(ButtonKey* button) {
|
||||||
return _take_button(button, &button_pressed);
|
return _take_button(button, &button_pressed);
|
||||||
}
|
}
|
||||||
bool get_released_button(ButtonKey* button) {
|
bool get_button_released(ButtonKey* button) {
|
||||||
return _take_button(button, &button_released);
|
return _take_button(button, &button_released);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t get_button_state() {
|
uint8_t get_button_state() {
|
||||||
return (uint8_t)((button_state >> 8) & 0xF);
|
return button_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_flipped_up_switch(SwitchKey* switch_) {
|
bool get_switch_flipped_up(SwitchKey* switch_) {
|
||||||
return _take_switch(switch_, &button_released);
|
return _take_switch(switch_, &switch_flipped_up);
|
||||||
}
|
}
|
||||||
bool get_flipped_down_switch(SwitchKey* switch_) {
|
bool get_switch_flipped_down(SwitchKey* switch_) {
|
||||||
return _take_switch(switch_, &button_released);
|
return _take_switch(switch_, &switch_flipped_down);
|
||||||
}
|
}
|
||||||
bool get_flipped_switch(SwitchKey* switch_) {
|
bool get_switch_flipped(SwitchKey* switch_) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int bit_selector = (1 << (i+4));
|
int bit_selector = (1 << i);
|
||||||
if (button_pressed & bit_selector || button_released & bit_selector) {
|
if (
|
||||||
|
((switch_flipped_up & bit_selector) != 0) ||
|
||||||
|
((switch_flipped_down & bit_selector) != 0)
|
||||||
|
) {
|
||||||
if (switch_ != nullptr) {
|
if (switch_ != nullptr) {
|
||||||
*switch_ = (SwitchKey) i;
|
*switch_ = (SwitchKey) i;
|
||||||
}
|
}
|
||||||
@@ -149,11 +292,21 @@ bool get_flipped_switch(SwitchKey* switch_) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t get_switch_state() {
|
uint8_t get_switch_state() {
|
||||||
return (uint8_t)(~button_state & 0xF);
|
return switch_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get_switch_touch_pressed(SwitchKey* switch_) {
|
||||||
|
return _take_switch(switch_, &switch_touch_pressed);
|
||||||
|
}
|
||||||
|
bool get_switch_touch_released(SwitchKey* switch_) {
|
||||||
|
return _take_switch(switch_, &switch_touch_released);
|
||||||
|
}
|
||||||
|
uint8_t get_switch_touch_state(){
|
||||||
|
return switch_touch_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool get_touch_state(void) {
|
bool get_touch_state(void) {
|
||||||
return touch_state;
|
return touch_state;
|
||||||
}
|
}
|
||||||
@@ -167,121 +320,3 @@ bool get_touch_released(void) {
|
|||||||
touch_released = false;
|
touch_released = false;
|
||||||
return return_;
|
return return_;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void poll_bottom_task(void *arg);
|
|
||||||
static void receive_keypad(void);
|
|
||||||
static void receive_button(void);
|
|
||||||
static void receive_touch(void);
|
|
||||||
|
|
||||||
// static void IRAM_ATTR gpio_isr_handler(void* arg)
|
|
||||||
// {
|
|
||||||
// // TODO: do somthing
|
|
||||||
// ESP_LOGI("BOTTOM_HALF", "Hit");
|
|
||||||
// }
|
|
||||||
|
|
||||||
void init_bottom_half() {
|
|
||||||
i2c_config_t conf = {
|
|
||||||
.mode = I2C_MODE_MASTER,
|
|
||||||
.sda_io_num = GPIO_NUM_5,
|
|
||||||
.scl_io_num = GPIO_NUM_6,
|
|
||||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
|
||||||
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
|
||||||
.master = {
|
|
||||||
.clk_speed = 100000,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(i2c_param_config(BOTTOM_I2C_NUM, &conf));
|
|
||||||
ESP_ERROR_CHECK(i2c_driver_install(BOTTOM_I2C_NUM, conf.mode, 0, 0, 0));
|
|
||||||
|
|
||||||
gpio_config_t delta_pin_conf = {};
|
|
||||||
// delta_pin_conf.intr_type = GPIO_INTR_LOW_LEVEL;
|
|
||||||
delta_pin_conf.mode = GPIO_MODE_INPUT;
|
|
||||||
// GPIO 0
|
|
||||||
delta_pin_conf.pin_bit_mask = (1ULL<<BOTTOM_PIN_INTERUPT);
|
|
||||||
delta_pin_conf.pull_up_en = GPIO_PULLUP_ENABLE;
|
|
||||||
gpio_config(&delta_pin_conf);
|
|
||||||
|
|
||||||
//install gpio isr service
|
|
||||||
// gpio_install_isr_service(0);
|
|
||||||
//hook isr handler for specific gpio pin
|
|
||||||
// gpio_isr_handler_add(BOTTOM_INTERUPT_PIN, gpio_isr_handler, NULL);
|
|
||||||
|
|
||||||
receive_keypad();
|
|
||||||
receive_button();
|
|
||||||
receive_touch();
|
|
||||||
|
|
||||||
xTaskCreate(poll_bottom_task, "poll_bottom", 4096, NULL, 10, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t receive_delta(void) {
|
|
||||||
uint8_t reg = 1;
|
|
||||||
buf[0] = 0;
|
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS)));
|
|
||||||
return buf[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void receive_keypad(void) {
|
|
||||||
uint8_t reg = 2;
|
|
||||||
buf[0] = 0;
|
|
||||||
buf[1] = 0;
|
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 2, (100 / portTICK_PERIOD_MS)));
|
|
||||||
uint16_t new_keypad_state = buf[0] | (buf[1] << 8);
|
|
||||||
|
|
||||||
uint16_t just_pressed = new_keypad_state & ~keypad_state;
|
|
||||||
keypad_pressed |= just_pressed;
|
|
||||||
|
|
||||||
uint16_t just_released = ~new_keypad_state & keypad_state;
|
|
||||||
keypad_released |= just_released;
|
|
||||||
|
|
||||||
keypad_state = new_keypad_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void receive_button(void) {
|
|
||||||
uint8_t reg = 3;
|
|
||||||
buf[0] = 0;
|
|
||||||
buf[1] = 0;
|
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 2, (100 / portTICK_PERIOD_MS)));
|
|
||||||
uint16_t new_button_state = buf[0] | (buf[1] << 8);
|
|
||||||
|
|
||||||
uint16_t just_pressed = new_button_state & ~button_state;
|
|
||||||
button_pressed |= just_pressed;
|
|
||||||
|
|
||||||
uint16_t just_released = ~new_button_state & button_state;
|
|
||||||
button_released |= just_released;
|
|
||||||
|
|
||||||
button_state = new_button_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void receive_touch(void) {
|
|
||||||
uint8_t reg = 4;
|
|
||||||
buf[0] = 0;
|
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS)));
|
|
||||||
bool new_touch_state = buf[0] != 0;
|
|
||||||
|
|
||||||
bool just_pressed = new_touch_state & !touch_state;
|
|
||||||
touch_pressed |= just_pressed;
|
|
||||||
|
|
||||||
bool just_released = (!new_touch_state) & touch_state;
|
|
||||||
touch_released |= just_released;
|
|
||||||
|
|
||||||
touch_state = new_touch_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void poll_bottom_task(void *arg) {
|
|
||||||
while (1) {
|
|
||||||
bool new_data = gpio_get_level(BOTTOM_PIN_INTERUPT) == 0;
|
|
||||||
if (new_data) {
|
|
||||||
uint8_t delta = receive_delta();
|
|
||||||
// ESP_LOGI(_TAG, "delta: %d", delta);
|
|
||||||
if (delta == 0) ESP_LOGW(TAG, "delta pin was low, but delta register returned 0");
|
|
||||||
|
|
||||||
if (delta & (1 << DELTA_BIT_KP)) receive_keypad();
|
|
||||||
if (delta & (1 << DELTA_BIT_BUTTON)) receive_button();
|
|
||||||
if (delta & (1 << DELTA_BIT_TOUCH)) receive_touch();
|
|
||||||
}
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
|
||||||
}
|
|
||||||
|
|
||||||
vTaskDelete(NULL);
|
|
||||||
}
|
|
||||||
+82
-20
@@ -10,9 +10,10 @@
|
|||||||
#define BOTTOM_PIN_INTERUPT GPIO_NUM_0
|
#define BOTTOM_PIN_INTERUPT GPIO_NUM_0
|
||||||
|
|
||||||
#define DELTA_BIT_KP 0
|
#define DELTA_BIT_KP 0
|
||||||
#define DELTA_BIT_BUTTON 1
|
#define DELTA_BIT_BUTTON_SWITCH 1
|
||||||
#define DELTA_BIT_TOUCH 2
|
#define DELTA_BIT_TOUCH 2
|
||||||
|
|
||||||
|
/// @brief An enum for the possible keypad buttons.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
k1 = 0,
|
k1 = 0,
|
||||||
k4 = 1,
|
k4 = 1,
|
||||||
@@ -32,13 +33,19 @@ typedef enum {
|
|||||||
kd = 15,
|
kd = 15,
|
||||||
} KeypadKey;
|
} KeypadKey;
|
||||||
|
|
||||||
|
/// @brief An enum for the possible buttons.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
b1 = 0,
|
b1 = 0,
|
||||||
b2 = 1,
|
b2 = 1,
|
||||||
b3 = 2,
|
b3 = 2,
|
||||||
b4 = 3,
|
b4 = 3,
|
||||||
|
button_green = 0,
|
||||||
|
button_red = 1,
|
||||||
|
button_yellow = 2,
|
||||||
|
button_blue = 3,
|
||||||
} ButtonKey;
|
} ButtonKey;
|
||||||
|
|
||||||
|
/// @brief An enum for the possible switches.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
s1 = 0,
|
s1 = 0,
|
||||||
s2 = 1,
|
s2 = 1,
|
||||||
@@ -46,25 +53,80 @@ typedef enum {
|
|||||||
s4 = 3,
|
s4 = 3,
|
||||||
} SwitchKey;
|
} SwitchKey;
|
||||||
|
|
||||||
void clear_all_pressed_released(void);
|
/// @brief Initializes communication with the bottom half.
|
||||||
|
|
||||||
bool get_pressed_keypad(KeypadKey* kp);
|
|
||||||
bool get_released_keypad(KeypadKey* kp);
|
|
||||||
char char_of_keypad_key(KeypadKey kp);
|
|
||||||
|
|
||||||
bool get_pressed_button(ButtonKey* button);
|
|
||||||
bool get_released_button(ButtonKey* button);
|
|
||||||
uint8_t get_button_state();
|
|
||||||
|
|
||||||
bool get_flipped_up_switch(SwitchKey* switch_);
|
|
||||||
bool get_flipped_down_switch(SwitchKey* switch_);
|
|
||||||
bool get_flipped_switch(SwitchKey* switch_);
|
|
||||||
uint8_t get_switch_state();
|
|
||||||
|
|
||||||
bool get_touch_state(void);
|
|
||||||
bool get_touch_pressed(void);
|
|
||||||
bool get_touch_released(void);
|
|
||||||
|
|
||||||
void init_bottom_half();
|
void init_bottom_half();
|
||||||
|
|
||||||
|
/// Clears all pending pressed/released switches/buttons/keys/touch sensors.
|
||||||
|
void clear_all_pressed_released();
|
||||||
|
|
||||||
|
/// @brief Gets the key that was just pressed (if any)
|
||||||
|
/// @param kp an OUT variable for the key that was pressed (if any)
|
||||||
|
/// @return true if there was a key that was just pressed
|
||||||
|
bool get_keypad_pressed(KeypadKey* kp);
|
||||||
|
/// @brief Gets the key that was just released (if any)
|
||||||
|
/// @param kp an OUT variable for the key that was released (if any)
|
||||||
|
/// @return true if there was a key that was just released
|
||||||
|
bool get_keypad_released(KeypadKey* kp);
|
||||||
|
/// @brief Converts a `KeypadKey` to a char
|
||||||
|
/// @param kp The value to convert
|
||||||
|
/// @return The char representing the key
|
||||||
|
char char_of_keypad_key(KeypadKey kp);
|
||||||
|
// TODO: add a get_keypad state?
|
||||||
|
|
||||||
|
|
||||||
|
/// @brief Gets the button that was just pressed (if any)
|
||||||
|
/// @param button an OUT variable for the button that was pressed (if any)
|
||||||
|
/// @return true if there was a button that was just pressed
|
||||||
|
bool get_button_pressed(ButtonKey* button);
|
||||||
|
/// @brief Gets the button that was just released (if any)
|
||||||
|
/// @param button an OUT variable for the button that was released (if any)
|
||||||
|
/// @return true if there was a button that was just released
|
||||||
|
bool get_button_released(ButtonKey* button);
|
||||||
|
/// @brief Gets the raw state of the buttons b1-b4 as bitflags.
|
||||||
|
/// B1 is MSB and B4 is LSB.
|
||||||
|
/// @return Bitflags for b1-b4.
|
||||||
|
uint8_t get_button_state();
|
||||||
|
|
||||||
|
/// @brief Gets the switch that was just flipped up (if any)
|
||||||
|
/// @param switch_ an OUT variable for the switch that was flipped up (if any)
|
||||||
|
/// @return true if there was a switch that was just flipped up
|
||||||
|
bool get_switch_flipped_up(SwitchKey* switch_);
|
||||||
|
/// @brief Gets the switch that was just flipped down (if any)
|
||||||
|
/// @param switch_ an OUT variable for the switch that was flipped down (if any)
|
||||||
|
/// @return true if there was a switch that was just flipped down
|
||||||
|
bool get_switch_flipped_down(SwitchKey* switch_);
|
||||||
|
/// @brief Gets the switch that was just flipped (if any)
|
||||||
|
/// @param switch_ an OUT variable for the switch that was flipped (if any)
|
||||||
|
/// @return true if there was a switch that was just flipped
|
||||||
|
bool get_switch_flipped(SwitchKey* switch_);
|
||||||
|
/// @brief Gets the raw state of the switches s1-s4 as bitflags.
|
||||||
|
/// S1 is MSB and S4 is LSB.
|
||||||
|
/// @return Bitflags for s1-s4.
|
||||||
|
uint8_t get_switch_state();
|
||||||
|
|
||||||
|
/// @brief Gets the switch that was just touched (if any)
|
||||||
|
/// @param switch_ an OUT variable for the switch that was touched (if any)
|
||||||
|
/// @return true if there was a switch that was just touched
|
||||||
|
bool get_switch_touch_pressed(SwitchKey* switch_);
|
||||||
|
/// @brief Gets the switch that was just un-touched (if any)
|
||||||
|
/// @param switch_ an OUT variable for the switch that was un-touched (if any)
|
||||||
|
/// @return true if there was a switch that was just un-touched
|
||||||
|
bool get_switch_touch_released(SwitchKey* switch_);
|
||||||
|
/// @brief Gets the raw state of the touched switches s1-s4 as bitflags.
|
||||||
|
/// S1 is MSB and S4 is LSB.
|
||||||
|
/// @return Bitflags for the touched state of S1-S4.
|
||||||
|
uint8_t get_switch_touch_state();
|
||||||
|
|
||||||
|
/// @brief Gets the state of the fingerprint sensor
|
||||||
|
/// @return true if the fingerprint sensor is touched
|
||||||
|
bool get_touch_state();
|
||||||
|
/// @brief Gets whether or not the touch sensor was just pressed
|
||||||
|
/// @return true if the touch sensor was just pressed
|
||||||
|
bool get_touch_pressed();
|
||||||
|
/// @brief Gets whether or not the touch sensor was just released
|
||||||
|
/// @return true if the touch sensor was just released
|
||||||
|
bool get_touch_released();
|
||||||
|
|
||||||
|
// TODO: add touch sensor for switch
|
||||||
|
|
||||||
#endif /* BOTTOM_HALF_HPP */
|
#endif /* BOTTOM_HALF_HPP */
|
||||||
@@ -1,14 +1,99 @@
|
|||||||
#include "char_lcd.h"
|
#include "char_lcd.h"
|
||||||
|
|
||||||
|
#include "./i2c_lcd_pcf8574.h"
|
||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
i2c_lcd_pcf8574_handle_t lcd;
|
i2c_lcd_pcf8574_handle_t lcd;
|
||||||
|
|
||||||
static const char *TAG = "char_lcd";
|
static const char *TAG = "char_lcd";
|
||||||
|
|
||||||
void init_char_lcd(void) {
|
void init_lcd() {
|
||||||
|
ESP_LOGI(TAG, "Initializing LCD...");
|
||||||
|
|
||||||
lcd_init(&lcd, LCD_ADDR, CHAR_LCD_I2C_NUM);
|
lcd_init(&lcd, LCD_ADDR, CHAR_LCD_I2C_NUM);
|
||||||
lcd_begin(&lcd, LCD_COLS, LCD_ROWS);
|
lcd_begin(&lcd, LCD_COLS, LCD_ROWS);
|
||||||
|
|
||||||
lcd_set_backlight(&lcd, 255);
|
lcd_set_backlight(&lcd, 255);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "LCD initialized");
|
ESP_LOGI(TAG, "LCD initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void lcd_clear() {
|
||||||
|
lcd_clear(&lcd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_cursor_home() {
|
||||||
|
lcd_home(&lcd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_set_cursor_pos(uint8_t col, uint8_t row) {
|
||||||
|
lcd_set_cursor(&lcd, col, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_set_display(bool display) {
|
||||||
|
if (display) {
|
||||||
|
lcd_display(&lcd);
|
||||||
|
} else {
|
||||||
|
lcd_no_display(&lcd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_set_cursor_vis(bool cursor) {
|
||||||
|
if (cursor) {
|
||||||
|
lcd_cursor(&lcd);
|
||||||
|
} else {
|
||||||
|
lcd_no_cursor(&lcd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_set_cursor_blink(bool blink) {
|
||||||
|
if (blink) {
|
||||||
|
lcd_blink(&lcd);
|
||||||
|
} else {
|
||||||
|
lcd_no_blink(&lcd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_scroll_display_left() {
|
||||||
|
lcd_scroll_display_left(&lcd);
|
||||||
|
}
|
||||||
|
void lcd_scroll_display_right() {
|
||||||
|
lcd_scroll_display_right(&lcd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_left_to_right() {
|
||||||
|
lcd_left_to_right(&lcd);
|
||||||
|
}
|
||||||
|
void lcd_right_to_left() {
|
||||||
|
lcd_right_to_left(&lcd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_set_autoscroll(bool autoscroll) {
|
||||||
|
if (autoscroll) {
|
||||||
|
lcd_autoscroll(&lcd);
|
||||||
|
} else {
|
||||||
|
lcd_no_autoscroll(&lcd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_set_backlight(uint8_t brightness) {
|
||||||
|
lcd_set_backlight(&lcd, brightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_create_char(uint8_t location, uint8_t charmap[]) {
|
||||||
|
lcd_create_char(&lcd, location, charmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_write(uint8_t value) {
|
||||||
|
lcd_write(&lcd, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_print(const char* str) {
|
||||||
|
lcd_print(&lcd, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_print(uint8_t col, uint8_t row, const char* str) {
|
||||||
|
lcd_set_cursor_pos(col, row);
|
||||||
|
lcd_print(&lcd, str);
|
||||||
}
|
}
|
||||||
+48
-4
@@ -1,8 +1,7 @@
|
|||||||
#ifndef CHAR_LCD_H
|
#ifndef CHAR_LCD_H
|
||||||
#define CHAR_LCD_H
|
#define CHAR_LCD_H
|
||||||
|
|
||||||
#include "i2c_lcd_pcf8574.h"
|
#include <cstdint>
|
||||||
#include <esp_log.h>
|
|
||||||
|
|
||||||
#define CHAR_LCD_I2C_NUM I2C_NUM_0
|
#define CHAR_LCD_I2C_NUM I2C_NUM_0
|
||||||
|
|
||||||
@@ -10,8 +9,53 @@
|
|||||||
#define LCD_COLS 20
|
#define LCD_COLS 20
|
||||||
#define LCD_ROWS 4
|
#define LCD_ROWS 4
|
||||||
|
|
||||||
extern i2c_lcd_pcf8574_handle_t lcd;
|
/// Initializes the 2004 Character LCD
|
||||||
|
void init_lcd();
|
||||||
|
|
||||||
void init_char_lcd(void);
|
/// Clear the LCD
|
||||||
|
void lcd_clear();
|
||||||
|
|
||||||
|
/// Move cursor to home position
|
||||||
|
void lcd_cursor_home();
|
||||||
|
|
||||||
|
/// Set cursor position
|
||||||
|
void lcd_set_cursor_pos(uint8_t col, uint8_t row);
|
||||||
|
|
||||||
|
/// Turn the display on/off
|
||||||
|
void lcd_set_display(bool display);
|
||||||
|
|
||||||
|
/// Turn the cursor's visibility on/off
|
||||||
|
void lcd_set_cursor_vis(bool cursor);
|
||||||
|
|
||||||
|
/// Turn blinking cursor on/off
|
||||||
|
void lcd_set_cursor_blink(bool blink);
|
||||||
|
|
||||||
|
/// Scroll the display left
|
||||||
|
void lcd_scroll_display_left();
|
||||||
|
/// Scroll the display right
|
||||||
|
void lcd_scroll_display_right();
|
||||||
|
|
||||||
|
/// Set the text to flows automatically left to right
|
||||||
|
void lcd_left_to_right();
|
||||||
|
/// Set the text to flows automatically right to left
|
||||||
|
void lcd_right_to_left();
|
||||||
|
|
||||||
|
// Turn on/off autoscroll
|
||||||
|
void lcd_set_autoscroll(bool autoscroll);
|
||||||
|
|
||||||
|
// Set backlight brightness
|
||||||
|
void lcd_set_backlight(uint8_t brightness);
|
||||||
|
|
||||||
|
// Create a custom character
|
||||||
|
void lcd_create_char(uint8_t location, uint8_t charmap[]);
|
||||||
|
|
||||||
|
// Write a character to the LCD
|
||||||
|
void lcd_write(uint8_t value);
|
||||||
|
|
||||||
|
// Print a string to the LCD
|
||||||
|
void lcd_print(const char* str);
|
||||||
|
|
||||||
|
// Print a string to the LCD at a given pos
|
||||||
|
void lcd_print(uint8_t col, uint8_t row, const char* str);
|
||||||
|
|
||||||
#endif /* CHAR_LCD_H */
|
#endif /* CHAR_LCD_H */
|
||||||
@@ -0,0 +1,467 @@
|
|||||||
|
// Addapted from:
|
||||||
|
// https://github.com/atanisoft/esp_lcd_ili9488
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 atanisoft (github.com/atanisoft)
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <driver/gpio.h>
|
||||||
|
#include <esp_lcd_panel_interface.h>
|
||||||
|
#include <esp_lcd_panel_io.h>
|
||||||
|
#include <esp_lcd_panel_vendor.h>
|
||||||
|
#include <esp_lcd_panel_ops.h>
|
||||||
|
#include <esp_lcd_panel_commands.h>
|
||||||
|
#include <esp_log.h>
|
||||||
|
#include <esp_rom_gpio.h>
|
||||||
|
#include <esp_check.h>
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
static const char *TAG = "ili9488";
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t cmd;
|
||||||
|
uint8_t data[16];
|
||||||
|
uint8_t data_bytes;
|
||||||
|
} lcd_init_cmd_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
esp_lcd_panel_t base;
|
||||||
|
esp_lcd_panel_io_handle_t io;
|
||||||
|
int reset_gpio_num;
|
||||||
|
bool reset_level;
|
||||||
|
int x_gap;
|
||||||
|
int y_gap;
|
||||||
|
uint8_t memory_access_control;
|
||||||
|
uint8_t color_mode;
|
||||||
|
size_t buffer_size;
|
||||||
|
uint8_t *color_buffer;
|
||||||
|
} ili9488_panel_t;
|
||||||
|
|
||||||
|
enum ili9488_constants
|
||||||
|
{
|
||||||
|
ILI9488_INTRFC_MODE_CTL = 0xB0,
|
||||||
|
ILI9488_FRAME_RATE_NORMAL_CTL = 0xB1,
|
||||||
|
ILI9488_INVERSION_CTL = 0xB4,
|
||||||
|
ILI9488_FUNCTION_CTL = 0xB6,
|
||||||
|
ILI9488_ENTRY_MODE_CTL = 0xB7,
|
||||||
|
ILI9488_POWER_CTL_ONE = 0xC0,
|
||||||
|
ILI9488_POWER_CTL_TWO = 0xC1,
|
||||||
|
ILI9488_POWER_CTL_THREE = 0xC5,
|
||||||
|
ILI9488_POSITIVE_GAMMA_CTL = 0xE0,
|
||||||
|
ILI9488_NEGATIVE_GAMMA_CTL = 0xE1,
|
||||||
|
ILI9488_ADJUST_CTL_THREE = 0xF7,
|
||||||
|
|
||||||
|
ILI9488_COLOR_MODE_16BIT = 0x55,
|
||||||
|
ILI9488_COLOR_MODE_18BIT = 0x66,
|
||||||
|
|
||||||
|
ILI9488_INTERFACE_MODE_USE_SDO = 0x00,
|
||||||
|
ILI9488_INTERFACE_MODE_IGNORE_SDO = 0x80,
|
||||||
|
|
||||||
|
ILI9488_IMAGE_FUNCTION_DISABLE_24BIT_DATA = 0x00,
|
||||||
|
|
||||||
|
ILI9488_WRITE_MODE_BCTRL_DD_ON = 0x28,
|
||||||
|
ILI9488_FRAME_RATE_60HZ = 0xA0,
|
||||||
|
|
||||||
|
ILI9488_INIT_LENGTH_MASK = 0x1F,
|
||||||
|
ILI9488_INIT_DONE_FLAG = 0xFF
|
||||||
|
};
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_del(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
|
||||||
|
if (ili9488->reset_gpio_num >= 0)
|
||||||
|
{
|
||||||
|
gpio_reset_pin(ili9488->reset_gpio_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ili9488->color_buffer != NULL)
|
||||||
|
{
|
||||||
|
heap_caps_free(ili9488->color_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "del ili9488 panel @%p", ili9488);
|
||||||
|
free(ili9488);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_reset(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
esp_lcd_panel_io_handle_t io = ili9488->io;
|
||||||
|
|
||||||
|
if (ili9488->reset_gpio_num >= 0)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Setting GPIO:%d to %d", ili9488->reset_gpio_num,
|
||||||
|
ili9488->reset_level);
|
||||||
|
// perform hardware reset
|
||||||
|
gpio_set_level(ili9488->reset_gpio_num, ili9488->reset_level);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
ESP_LOGI(TAG, "Setting GPIO:%d to %d", ili9488->reset_gpio_num,
|
||||||
|
!ili9488->reset_level);
|
||||||
|
gpio_set_level(ili9488->reset_gpio_num, !ili9488->reset_level);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Sending SW_RESET to display");
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET, NULL, 0);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(20));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_init(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
esp_lcd_panel_io_handle_t io = ili9488->io;
|
||||||
|
|
||||||
|
// ORIGINAL
|
||||||
|
lcd_init_cmd_t ili9488_init[] =
|
||||||
|
{
|
||||||
|
#if CONFIG_USE_NEW_DISPLAY
|
||||||
|
{ ILI9488_POSITIVE_GAMMA_CTL, { 0x00, 0x08, 0x0c, 0x02, 0x0e, 0x04, 0x30, 0x45, 0x47, 0x04, 0x0C, 0x0a, 0x2e, 0x34, 0x0F }, 15 },
|
||||||
|
{ ILI9488_NEGATIVE_GAMMA_CTL, { 0x00, 0x11, 0x0d, 0x01, 0x0f, 0x05, 0x39, 0x36, 0x51, 0x06, 0x0f, 0x0d, 0x33, 0x37, 0x0F }, 15 },
|
||||||
|
#else
|
||||||
|
{ ILI9488_POSITIVE_GAMMA_CTL, { 0x00, 0x03, 0x09, 0x08, 0x16, 0x0A, 0x3F, 0x78, 0x4C, 0x09, 0x0A, 0x08, 0x16, 0x1A, 0x0F }, 15 },
|
||||||
|
{ ILI9488_NEGATIVE_GAMMA_CTL, { 0x00, 0x16, 0x19, 0x03, 0x0F, 0x05, 0x32, 0x45, 0x46, 0x04, 0x0E, 0x0D, 0x35, 0x37, 0x0F }, 15 },
|
||||||
|
#endif /* CONFIG_USE_NEW_DISPLAY */
|
||||||
|
|
||||||
|
{ ILI9488_POWER_CTL_ONE, { 0x17, 0x15 }, 2 },
|
||||||
|
{ ILI9488_POWER_CTL_TWO, { 0x41 }, 1 },
|
||||||
|
{ ILI9488_POWER_CTL_THREE, { 0x00, 0x12, 0x80 }, 3 },
|
||||||
|
{ LCD_CMD_MADCTL, { ili9488->memory_access_control }, 1 },
|
||||||
|
{ LCD_CMD_COLMOD, { ili9488->color_mode }, 1 },
|
||||||
|
{ ILI9488_INTRFC_MODE_CTL, { ILI9488_INTERFACE_MODE_USE_SDO }, 1 },
|
||||||
|
{ ILI9488_FRAME_RATE_NORMAL_CTL, { ILI9488_FRAME_RATE_60HZ }, 1 },
|
||||||
|
{ ILI9488_INVERSION_CTL, { 0x02 }, 1 },
|
||||||
|
{ ILI9488_FUNCTION_CTL, { 0x02, 0x02, 0x3B }, 3},
|
||||||
|
{ ILI9488_ENTRY_MODE_CTL, { 0xC6 }, 1 },
|
||||||
|
{ ILI9488_ADJUST_CTL_THREE, { 0xA9, 0x51, 0x2C, 0x02 }, 4 },
|
||||||
|
{ LCD_CMD_NOP, { 0 }, ILI9488_INIT_DONE_FLAG },
|
||||||
|
};
|
||||||
|
|
||||||
|
// WITH CONSTS INLINED:
|
||||||
|
// lcd_init_cmd_t ili9488_init[] =
|
||||||
|
// {
|
||||||
|
// { 0xE0,
|
||||||
|
// { 0x00, 0x03, 0x09, 0x08, 0x16,
|
||||||
|
// 0x0A, 0x3F, 0x78, 0x4C, 0x09,
|
||||||
|
// 0x0A, 0x08, 0x16, 0x1A, 0x0F },
|
||||||
|
// 15
|
||||||
|
// },
|
||||||
|
// { 0xE1,
|
||||||
|
// { 0x00, 0x16, 0x19, 0x03, 0x0F,
|
||||||
|
// 0x05, 0x32, 0x45, 0x46, 0x04,
|
||||||
|
// 0x0E, 0x0D, 0x35, 0x37, 0x0F},
|
||||||
|
// 15
|
||||||
|
// },
|
||||||
|
// { 0xC0, { 0x17, 0x15 }, 2 },
|
||||||
|
// { 0xC1, { 0x41 }, 1 },
|
||||||
|
// { 0xC5, { 0x00, 0x12, 0x80 }, 3 },
|
||||||
|
// { 0x36, { ili9488->memory_access_control }, 1 },
|
||||||
|
// { 0x3A, { ili9488->color_mode }, 1 },
|
||||||
|
// { 0xB0, { ILI9488_INTERFACE_MODE_USE_SDO }, 1 },
|
||||||
|
// { 0xB1, { ILI9488_FRAME_RATE_60HZ }, 1 },
|
||||||
|
// { 0xB4, { 0x02 }, 1 },
|
||||||
|
// { 0xB6, { 0x02, 0x02, 0x3B }, 3},
|
||||||
|
// { 0xB7, { 0xC6 }, 1 },
|
||||||
|
// { 0xF7, { 0xA9, 0x51, 0x2C, 0x02 }, 4 },
|
||||||
|
// { 0x00, { 0 }, ILI9488_INIT_DONE_FLAG },
|
||||||
|
// };
|
||||||
|
|
||||||
|
// code from LCD manufacturer. (Not working):
|
||||||
|
// lcd_init_cmd_t ili9488_init[] = {
|
||||||
|
// { 0xF7, { 0xA9, 0x51, 0x2C, 0x82 }, 4 },
|
||||||
|
// { 0x36, { 0x48 }, 1 },
|
||||||
|
// { 0x3A, { 0x55 }, 1 },
|
||||||
|
// { 0xB4, { 0x02 }, 1 },
|
||||||
|
// { 0xB1, { 0xA0, 0x11 }, 2 },
|
||||||
|
// { 0xC0, { 0x0F, 0x0F }, 2 },
|
||||||
|
// { 0xC1, { 0x41 }, 1 },
|
||||||
|
// { 0xC2, { 0x22 }, 1 },
|
||||||
|
// { 0xB7, { 0xC6 }, 1 },
|
||||||
|
// { 0xc5, { 0x00, 0x53, 0x80 }, 3 },
|
||||||
|
// { 0xE0, { 0x00, 0x08, 0x0c, 0x02, 0x0e, 0x04, 0x30, 0x45, 0x47, 0x04, 0x0C, 0x0a, 0x2e, 0x34, 0x0F }, 15 },
|
||||||
|
// { 0xE1, { 0x00, 0x11, 0x0d, 0x01, 0x0f, 0x05, 0x39, 0x36, 0x51, 0x06, 0x0f, 0x0d, 0x33, 0x37, 0x0F }, 15 },
|
||||||
|
// { 0x21, { 0x00 }, 1 },
|
||||||
|
// { 0x3A, { 0x55 }, 1 },
|
||||||
|
// { LCD_CMD_NOP, { 0 }, ILI9488_INIT_DONE_FLAG },
|
||||||
|
// };
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Initializing ILI9488");
|
||||||
|
int cmd = 0;
|
||||||
|
while ( ili9488_init[cmd].data_bytes != ILI9488_INIT_DONE_FLAG )
|
||||||
|
{
|
||||||
|
ESP_LOGD(TAG, "Sending CMD: %02x, len: %d", ili9488_init[cmd].cmd,
|
||||||
|
ili9488_init[cmd].data_bytes & ILI9488_INIT_LENGTH_MASK);
|
||||||
|
esp_lcd_panel_io_tx_param(
|
||||||
|
io, ili9488_init[cmd].cmd, ili9488_init[cmd].data,
|
||||||
|
ili9488_init[cmd].data_bytes & ILI9488_INIT_LENGTH_MASK);
|
||||||
|
cmd++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Take the display out of sleep mode.
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT, NULL, 0);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
|
||||||
|
// Turn on the display.
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_DISPON, NULL, 0);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Initialization complete");
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SEND_COORDS(start, end, io, cmd) \
|
||||||
|
esp_lcd_panel_io_tx_param(io, cmd, (uint8_t[]) { \
|
||||||
|
(start >> 8) & 0xFF, \
|
||||||
|
start & 0xFF, \
|
||||||
|
((end - 1) >> 8) & 0xFF, \
|
||||||
|
(end - 1) & 0xFF, \
|
||||||
|
}, 4)
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_draw_bitmap(
|
||||||
|
esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end,
|
||||||
|
const void *color_data)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
assert((x_start < x_end) && (y_start < y_end) &&
|
||||||
|
"starting position must be smaller than end position");
|
||||||
|
esp_lcd_panel_io_handle_t io = ili9488->io;
|
||||||
|
|
||||||
|
x_start += ili9488->x_gap;
|
||||||
|
x_end += ili9488->x_gap;
|
||||||
|
y_start += ili9488->y_gap;
|
||||||
|
y_end += ili9488->y_gap;
|
||||||
|
|
||||||
|
size_t color_data_len = (x_end - x_start) * (y_end - y_start);
|
||||||
|
|
||||||
|
SEND_COORDS(x_start, x_end, io, LCD_CMD_CASET);
|
||||||
|
SEND_COORDS(y_start, y_end, io, LCD_CMD_RASET);
|
||||||
|
|
||||||
|
// When the ILI9488 is used in 18-bit color mode we need to convert the
|
||||||
|
// incoming color data from RGB565 (16-bit) to RGB666.
|
||||||
|
//
|
||||||
|
// NOTE: 16-bit color does not work via SPI interface :(
|
||||||
|
if (ili9488->color_mode == ILI9488_COLOR_MODE_18BIT)
|
||||||
|
{
|
||||||
|
uint8_t *buf = ili9488->color_buffer;
|
||||||
|
uint16_t *raw_color_data = (uint16_t *) color_data;
|
||||||
|
for (uint32_t i = 0, pixel_index = 0; i < color_data_len; i++) {
|
||||||
|
buf[pixel_index++] = (uint8_t) (((raw_color_data[i] & 0xF800) >> 8) |
|
||||||
|
((raw_color_data[i] & 0x8000) >> 13));
|
||||||
|
buf[pixel_index++] = (uint8_t) ((raw_color_data[i] & 0x07E0) >> 3);
|
||||||
|
buf[pixel_index++] = (uint8_t) (((raw_color_data[i] & 0x001F) << 3) |
|
||||||
|
((raw_color_data[i] & 0x0010) >> 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, buf, color_data_len * 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 16-bit color we can transmit as-is to the display.
|
||||||
|
esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, color_data_len * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef SEND_COORDS
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_invert_color(
|
||||||
|
esp_lcd_panel_t *panel, bool invert_color_data)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
esp_lcd_panel_io_handle_t io = ili9488->io;
|
||||||
|
|
||||||
|
if (invert_color_data)
|
||||||
|
{
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_INVON, NULL, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_INVOFF, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_mirror(
|
||||||
|
esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
esp_lcd_panel_io_handle_t io = ili9488->io;
|
||||||
|
if (mirror_x)
|
||||||
|
{
|
||||||
|
ili9488->memory_access_control &= ~LCD_CMD_MX_BIT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ili9488->memory_access_control |= LCD_CMD_MX_BIT;
|
||||||
|
}
|
||||||
|
if (mirror_y)
|
||||||
|
{
|
||||||
|
ili9488->memory_access_control |= LCD_CMD_MY_BIT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ili9488->memory_access_control &= ~LCD_CMD_MY_BIT;
|
||||||
|
}
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, &ili9488->memory_access_control, 1);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_swap_xy(esp_lcd_panel_t *panel, bool swap_axes)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
esp_lcd_panel_io_handle_t io = ili9488->io;
|
||||||
|
if (swap_axes)
|
||||||
|
{
|
||||||
|
ili9488->memory_access_control |= LCD_CMD_MV_BIT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ili9488->memory_access_control &= ~LCD_CMD_MV_BIT;
|
||||||
|
}
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, &ili9488->memory_access_control, 1);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_set_gap(
|
||||||
|
esp_lcd_panel_t *panel, int x_gap, int y_gap)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
ili9488->x_gap = x_gap;
|
||||||
|
ili9488->y_gap = y_gap;
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_ili9488_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
|
||||||
|
{
|
||||||
|
ili9488_panel_t *ili9488 = __containerof(panel, ili9488_panel_t, base);
|
||||||
|
esp_lcd_panel_io_handle_t io = ili9488->io;
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||||
|
// In ESP-IDF v4.x the API used false for "on" and true for "off"
|
||||||
|
// invert the logic to be consistent with IDF v5.x.
|
||||||
|
on_off = !on_off;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (on_off)
|
||||||
|
{
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_DISPON, NULL, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
esp_lcd_panel_io_tx_param(io, LCD_CMD_DISPOFF, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// give time for the ILI9488 to recover after an on/off command
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_lcd_new_panel_ili9488(
|
||||||
|
const esp_lcd_panel_io_handle_t io,
|
||||||
|
const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||||
|
const size_t buffer_size,
|
||||||
|
esp_lcd_panel_handle_t *ret_panel)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
ili9488_panel_t *ili9488 = NULL;
|
||||||
|
ESP_GOTO_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG,
|
||||||
|
err, TAG, "invalid argument");
|
||||||
|
ili9488 = (ili9488_panel_t *)(calloc(1, sizeof(ili9488_panel_t)));
|
||||||
|
ESP_GOTO_ON_FALSE(ili9488, ESP_ERR_NO_MEM, err, TAG, "no mem for ili9488 panel");
|
||||||
|
|
||||||
|
if (panel_dev_config->reset_gpio_num >= 0)
|
||||||
|
{
|
||||||
|
gpio_config_t cfg;
|
||||||
|
memset(&cfg, 0, sizeof(gpio_config_t));
|
||||||
|
esp_rom_gpio_pad_select_gpio(panel_dev_config->reset_gpio_num);
|
||||||
|
cfg.pin_bit_mask = BIT64(panel_dev_config->reset_gpio_num);
|
||||||
|
cfg.mode = GPIO_MODE_OUTPUT;
|
||||||
|
ESP_GOTO_ON_ERROR(gpio_config(&cfg), err, TAG,
|
||||||
|
"configure GPIO for RESET line failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (panel_dev_config->bits_per_pixel == 16)
|
||||||
|
{
|
||||||
|
ili9488->color_mode = ILI9488_COLOR_MODE_16BIT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ESP_GOTO_ON_FALSE(buffer_size > 0, ESP_ERR_INVALID_ARG, err, TAG,
|
||||||
|
"Color conversion buffer size must be specified");
|
||||||
|
ili9488->color_mode = ILI9488_COLOR_MODE_18BIT;
|
||||||
|
|
||||||
|
// Allocate DMA buffer for color conversions
|
||||||
|
ili9488->color_buffer =
|
||||||
|
(uint8_t *)heap_caps_malloc(buffer_size * 3, MALLOC_CAP_DMA);
|
||||||
|
ESP_GOTO_ON_FALSE(ili9488->color_buffer, ESP_ERR_NO_MEM, err, TAG,
|
||||||
|
"Failed to allocate DMA color conversion buffer");
|
||||||
|
}
|
||||||
|
|
||||||
|
ili9488->memory_access_control = LCD_CMD_MX_BIT | LCD_CMD_BGR_BIT;
|
||||||
|
switch (panel_dev_config->color_space)
|
||||||
|
{
|
||||||
|
case ESP_LCD_COLOR_SPACE_RGB:
|
||||||
|
ESP_LOGI(TAG, "Configuring for RGB color order");
|
||||||
|
ili9488->memory_access_control &= ~LCD_CMD_BGR_BIT;
|
||||||
|
break;
|
||||||
|
case ESP_LCD_COLOR_SPACE_BGR:
|
||||||
|
ESP_LOGI(TAG, "Configuring for BGR color order");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ESP_GOTO_ON_FALSE(false, ESP_ERR_INVALID_ARG, err, TAG,
|
||||||
|
"Unsupported color mode!");
|
||||||
|
}
|
||||||
|
|
||||||
|
ili9488->io = io;
|
||||||
|
ili9488->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
||||||
|
ili9488->reset_level = panel_dev_config->flags.reset_active_high;
|
||||||
|
ili9488->base.del = panel_ili9488_del;
|
||||||
|
ili9488->base.reset = panel_ili9488_reset;
|
||||||
|
ili9488->base.init = panel_ili9488_init;
|
||||||
|
ili9488->base.draw_bitmap = panel_ili9488_draw_bitmap;
|
||||||
|
ili9488->base.invert_color = panel_ili9488_invert_color;
|
||||||
|
ili9488->base.set_gap = panel_ili9488_set_gap;
|
||||||
|
ili9488->base.mirror = panel_ili9488_mirror;
|
||||||
|
ili9488->base.swap_xy = panel_ili9488_swap_xy;
|
||||||
|
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||||
|
ili9488->base.disp_off = panel_ili9488_disp_on_off;
|
||||||
|
#else
|
||||||
|
ili9488->base.disp_on_off = panel_ili9488_disp_on_off;
|
||||||
|
#endif
|
||||||
|
*ret_panel = &(ili9488->base);
|
||||||
|
ESP_LOGI(TAG, "new ili9488 panel @%p", ili9488);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (ili9488)
|
||||||
|
{
|
||||||
|
if (panel_dev_config->reset_gpio_num >= 0)
|
||||||
|
{
|
||||||
|
gpio_reset_pin(panel_dev_config->reset_gpio_num);
|
||||||
|
}
|
||||||
|
if (ili9488->color_buffer != NULL)
|
||||||
|
{
|
||||||
|
heap_caps_free(ili9488->color_buffer);
|
||||||
|
}
|
||||||
|
free(ili9488);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// Addapted from:
|
||||||
|
// https://github.com/atanisoft/esp_lcd_ili9488
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 atanisoft (github.com/atanisoft)
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "esp_lcd_panel_vendor.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create LCD panel for model ILI9488
|
||||||
|
*
|
||||||
|
* @param[in] io LCD panel IO handle
|
||||||
|
* @param[in] panel_dev_config general panel device configuration
|
||||||
|
* @param[in] buffer_size size of buffer to allocate for color conversions.
|
||||||
|
* @param[out] ret_panel Returned LCD panel handle
|
||||||
|
* @return
|
||||||
|
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||||
|
* - ESP_ERR_NO_MEM if out of memory
|
||||||
|
* - ESP_OK on success
|
||||||
|
*
|
||||||
|
* NOTE: If you are using the SPI interface you *MUST* 18-bit color mode
|
||||||
|
* in @param panel_dev_config field bits_per_pixel and @param buffer_size
|
||||||
|
* must be provided.
|
||||||
|
*
|
||||||
|
* NOTE: For parallel IO (Intel 8080) interface 16-bit color mode should
|
||||||
|
* be used and @param buffer_size will be ignored.
|
||||||
|
|
||||||
|
*/
|
||||||
|
esp_err_t esp_lcd_new_panel_ili9488(const esp_lcd_panel_io_handle_t io,
|
||||||
|
const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||||
|
const size_t buffer_size,
|
||||||
|
esp_lcd_panel_handle_t *ret_panel);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -51,7 +51,7 @@ void stop_module_timer(void) {
|
|||||||
is_module_playing = false;
|
is_module_playing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_game_time(uint32_t new_time) {
|
void set_game_time(int32_t new_time) {
|
||||||
if (new_time > 0) {
|
if (new_time > 0) {
|
||||||
game_time_count_up = false;
|
game_time_count_up = false;
|
||||||
game_time_left = new_time;
|
game_time_left = new_time;
|
||||||
@@ -62,8 +62,12 @@ void set_game_time(uint32_t new_time) {
|
|||||||
write_game_time(game_time_left);
|
write_game_time(game_time_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_game_time() {
|
int32_t get_game_time() {
|
||||||
return game_time_left;
|
if (game_time_count_up) {
|
||||||
|
return -((int32_t) game_time_left);
|
||||||
|
} else {
|
||||||
|
return ((int32_t) game_time_left);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_module_time(uint32_t new_time) {
|
void set_module_time(uint32_t new_time) {
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ void start_module_timer(void);
|
|||||||
void stop_module_timer(void);
|
void stop_module_timer(void);
|
||||||
|
|
||||||
/// Sets the game time in ms
|
/// Sets the game time in ms
|
||||||
void set_game_time(uint32_t new_time);
|
void set_game_time(int32_t new_time);
|
||||||
/// Gets the current game time in ms
|
/// Gets the current game time in ms
|
||||||
uint32_t get_game_time();
|
int32_t get_game_time();
|
||||||
|
|
||||||
/// Gets the current game time in ms
|
/// Gets the current game time in ms
|
||||||
void time_penalty(uint32_t penalty);
|
void time_penalty(uint32_t penalty);
|
||||||
|
|||||||
@@ -0,0 +1,355 @@
|
|||||||
|
/// \file i2c_lcd_pcf8574.c
|
||||||
|
/// \brief Liquid Crystal display driver with PCF8574 adapter for esp-idf
|
||||||
|
///
|
||||||
|
/// \author Femi Olugbon, https://iamflinks.github.io
|
||||||
|
/// \copyright Copyright (c) 2024 by Femi Olugbon
|
||||||
|
///
|
||||||
|
/// ChangeLog see: i2c_lcd_pcf8574.h
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "i2c_lcd_pcf8574.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "esp_check.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
|
||||||
|
#define TAG "I2C_LCD_PCF8574"
|
||||||
|
|
||||||
|
#define I2C_MASTER_TIMEOUT_MS 1000
|
||||||
|
|
||||||
|
// private functions
|
||||||
|
static void lcd_send(i2c_lcd_pcf8574_handle_t* lcd, uint8_t value, bool is_data);
|
||||||
|
static void lcd_write_nibble(i2c_lcd_pcf8574_handle_t* lcd, uint8_t half_byte, bool is_data, i2c_cmd_handle_t cmd);
|
||||||
|
static void lcd_write_i2c(i2c_lcd_pcf8574_handle_t* lcd, uint8_t data, bool is_data, bool enable);
|
||||||
|
|
||||||
|
void lcd_init(i2c_lcd_pcf8574_handle_t* lcd, uint8_t i2c_addr, i2c_port_t i2c_port) {
|
||||||
|
lcd->i2c_addr = i2c_addr;
|
||||||
|
lcd->i2c_port = i2c_port;
|
||||||
|
lcd->backlight = 0;
|
||||||
|
lcd->entrymode = 0x02; // Init the LCD with an internal reset
|
||||||
|
lcd->displaycontrol = 0x04;
|
||||||
|
lcd->rs_mask = 0x01;
|
||||||
|
lcd->rw_mask = 0x00;
|
||||||
|
lcd->enable_mask = 0x04;
|
||||||
|
lcd->data_mask[0] = 0x10;
|
||||||
|
lcd->data_mask[1] = 0x20;
|
||||||
|
lcd->data_mask[2] = 0x40;
|
||||||
|
lcd->data_mask[3] = 0x80;
|
||||||
|
lcd->backlight_mask = 0x08;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_begin(i2c_lcd_pcf8574_handle_t* lcd, uint8_t cols, uint8_t rows) {
|
||||||
|
|
||||||
|
// Ensure the cols and rows stay within max limit
|
||||||
|
lcd->cols = (cols > 80) ? 80 : cols;
|
||||||
|
lcd->lines = (rows > 4) ? 4 : rows;
|
||||||
|
|
||||||
|
lcd->row_offsets[0] = 0x00;
|
||||||
|
lcd->row_offsets[1] = 0x40;
|
||||||
|
lcd->row_offsets[2] = 0x00 + cols;
|
||||||
|
lcd->row_offsets[3] = 0x40 + cols;
|
||||||
|
|
||||||
|
// Initialize the LCD
|
||||||
|
lcd_write_i2c(lcd, 0x00, false, false);
|
||||||
|
esp_rom_delay_us(50000);
|
||||||
|
|
||||||
|
// This follows after the reset mode
|
||||||
|
lcd->displaycontrol = 0x04;
|
||||||
|
lcd->entrymode = 0x02;
|
||||||
|
|
||||||
|
// The following are the reset sequence: Please see "Initialization instruction in the PCF8574 datasheet."
|
||||||
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
|
i2c_master_start(cmd);
|
||||||
|
// We left-shift the device addres and add the read/write command
|
||||||
|
i2c_master_write_byte(cmd, (lcd->i2c_addr << 1) | I2C_MASTER_WRITE, true);
|
||||||
|
|
||||||
|
lcd_write_nibble(lcd, 0x03, false, cmd);
|
||||||
|
i2c_master_stop(cmd);
|
||||||
|
i2c_master_cmd_begin(lcd->i2c_port, cmd, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||||
|
i2c_cmd_link_delete(cmd);
|
||||||
|
esp_rom_delay_us(4500);
|
||||||
|
|
||||||
|
cmd = i2c_cmd_link_create();
|
||||||
|
i2c_master_start(cmd);
|
||||||
|
i2c_master_write_byte(cmd, (lcd->i2c_addr << 1) | I2C_MASTER_WRITE, true);
|
||||||
|
lcd_write_nibble(lcd, 0x03, false, cmd);
|
||||||
|
i2c_master_stop(cmd);
|
||||||
|
i2c_master_cmd_begin(lcd->i2c_port, cmd, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||||
|
i2c_cmd_link_delete(cmd);
|
||||||
|
esp_rom_delay_us(200);
|
||||||
|
|
||||||
|
cmd = i2c_cmd_link_create();
|
||||||
|
i2c_master_start(cmd);
|
||||||
|
i2c_master_write_byte(cmd, (lcd->i2c_addr << 1) | I2C_MASTER_WRITE, true);
|
||||||
|
lcd_write_nibble(lcd, 0x03, false, cmd);
|
||||||
|
i2c_master_stop(cmd);
|
||||||
|
i2c_master_cmd_begin(lcd->i2c_port, cmd, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||||
|
i2c_cmd_link_delete(cmd);
|
||||||
|
esp_rom_delay_us(200);
|
||||||
|
|
||||||
|
// Set the data interface to 4-bit interface (PCF8574 uses 4-bit interface)
|
||||||
|
cmd = i2c_cmd_link_create();
|
||||||
|
i2c_master_start(cmd);
|
||||||
|
i2c_master_write_byte(cmd, (lcd->i2c_addr << 1) | I2C_MASTER_WRITE, true);
|
||||||
|
lcd_write_nibble(lcd, 0x02, false, cmd);
|
||||||
|
i2c_master_stop(cmd);
|
||||||
|
i2c_master_cmd_begin(lcd->i2c_port, cmd, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||||
|
i2c_cmd_link_delete(cmd);
|
||||||
|
|
||||||
|
// Instruction: function set = 0x20
|
||||||
|
lcd_send(lcd, 0x20 | (rows > 1 ? 0x08 : 0x00), false);
|
||||||
|
|
||||||
|
// Set the display parameters (turn on display, clear, and set left to right)
|
||||||
|
lcd_display(lcd);
|
||||||
|
lcd_clear(lcd);
|
||||||
|
lcd_left_to_right(lcd);
|
||||||
|
} // lcd_begin()
|
||||||
|
|
||||||
|
// Clear the display content
|
||||||
|
void lcd_clear(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Instruction: Clear display = 0x01
|
||||||
|
lcd_send(lcd, 0x01, false);
|
||||||
|
// Clearing the display takes a while: takes approx. 1.5ms
|
||||||
|
esp_rom_delay_us(1600);
|
||||||
|
} // lcd_clear()
|
||||||
|
|
||||||
|
// Set the display to home
|
||||||
|
void lcd_home(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Instruction: Return home = 0x02
|
||||||
|
lcd_send(lcd, 0x02, false);
|
||||||
|
// Same as clearing the display: takes approx. 1.5ms
|
||||||
|
esp_rom_delay_us(1600);
|
||||||
|
} // lcd_home()
|
||||||
|
|
||||||
|
// Set the cursor to a new position.
|
||||||
|
void lcd_set_cursor(i2c_lcd_pcf8574_handle_t* lcd, uint8_t col, uint8_t row) {
|
||||||
|
// Check the display boundaries
|
||||||
|
if (row >= lcd->lines) {
|
||||||
|
row = lcd->lines - 1;
|
||||||
|
}
|
||||||
|
if (col >= lcd->cols) {
|
||||||
|
col = lcd->cols - 1;
|
||||||
|
}
|
||||||
|
// Instruction: Set DDRAM address = 080
|
||||||
|
lcd_send(lcd, 0x80 | (lcd->row_offsets[row] + col), false);
|
||||||
|
} // lcd_set_cursor()
|
||||||
|
|
||||||
|
// Turn off the display: fast operation
|
||||||
|
void lcd_no_display(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Display Control: Display on/off control = 0x04
|
||||||
|
lcd->displaycontrol &= ~0x04;
|
||||||
|
// Instruction: Display mode: 0x08
|
||||||
|
lcd_send(lcd, 0x08 | lcd->displaycontrol, false);
|
||||||
|
} // lcd_no_display()
|
||||||
|
|
||||||
|
// Turn on the display: fast operation
|
||||||
|
void lcd_display(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Display Control: Display on/off control = 0x04
|
||||||
|
lcd->displaycontrol |= 0x04;
|
||||||
|
// Instruction: Display mode: 0x08
|
||||||
|
lcd_send(lcd, 0x08 | lcd->displaycontrol, false);
|
||||||
|
} // lcd_display()
|
||||||
|
|
||||||
|
// Turn on the cursor
|
||||||
|
void lcd_cursor(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Display Control: Cursor on/off control = 0x02
|
||||||
|
lcd->displaycontrol |= 0x02;
|
||||||
|
// Instruction: Display mode: 0x08
|
||||||
|
lcd_send(lcd, 0x08 | lcd->displaycontrol, false);
|
||||||
|
} // lcd_cursor()
|
||||||
|
|
||||||
|
// Turn off the cursor
|
||||||
|
void lcd_no_cursor(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Display Control: Cursor on/off control = 0x02
|
||||||
|
lcd->displaycontrol &= ~0x02;
|
||||||
|
// Instruction: Display mode: 0x08
|
||||||
|
lcd_send(lcd, 0x08 | lcd->displaycontrol, false);
|
||||||
|
} // lcd_no_cursor()
|
||||||
|
|
||||||
|
// Turn on the blinking
|
||||||
|
void lcd_blink(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Display Control: Blink on/off control = 0x01
|
||||||
|
lcd->displaycontrol |= 0x01;
|
||||||
|
// Instruction: Display mode: 0x08
|
||||||
|
lcd_send(lcd, 0x08 | lcd->displaycontrol, false);
|
||||||
|
} // lcd_blink()
|
||||||
|
|
||||||
|
// Turn off the blinking
|
||||||
|
void lcd_no_blink(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Display Control: Blink on/off control = 0x01
|
||||||
|
lcd->displaycontrol &= ~0x01;
|
||||||
|
// Instruction: Display mode: 0x08
|
||||||
|
lcd_send(lcd, 0x08 | lcd->displaycontrol, false);
|
||||||
|
} // lcd_no_blink()
|
||||||
|
|
||||||
|
// This command will scroll the display left by one step without changing the RAM
|
||||||
|
void lcd_scroll_display_left(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Instruction: Cursor or display shift - 0x10
|
||||||
|
// Instruction: Display mode: 0x08
|
||||||
|
// Control: Left shift control = 0x00
|
||||||
|
// 0x10 | 0x08 | 0x00 = 0x18
|
||||||
|
lcd_send(lcd, 0x18, false);
|
||||||
|
} // lcd_scroll_display_left()
|
||||||
|
|
||||||
|
// This command will scroll the display right by one step without changing the RAM
|
||||||
|
void lcd_scroll_display_right(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Instruction: Cursor or display shift - 0x10
|
||||||
|
// Instruction: Display mode: 0x08
|
||||||
|
// Control: Left shift control = 0x04
|
||||||
|
// 0x10 | 0x08 | 0x04 = 0x1C
|
||||||
|
lcd_send(lcd, 0x1C, false);
|
||||||
|
} // lcd_scroll_display_right()
|
||||||
|
|
||||||
|
// Controlling the entry mode: This is for text that flows left to right
|
||||||
|
void lcd_left_to_right(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Instruction: Entry mode set, set increment/decrement = 0x02
|
||||||
|
lcd->entrymode |= 0x02;
|
||||||
|
lcd_send(lcd, 0x04 | lcd->entrymode, false);
|
||||||
|
} // lcd_left_to_right()
|
||||||
|
|
||||||
|
// Controlling the entry mode: This is for text that flows right to left
|
||||||
|
void lcd_right_to_left(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Instruction: Entry mode set, clear increment/decrement = 0x02
|
||||||
|
lcd->entrymode &= ~0x02;
|
||||||
|
lcd_send(lcd, 0x04 | lcd->entrymode, false);
|
||||||
|
} // lcd_right_to_left()
|
||||||
|
|
||||||
|
// This will justify the text to the right from the cursor
|
||||||
|
void lcd_autoscroll(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Instruction: Entry mode set, set shift = 0x01
|
||||||
|
lcd->entrymode |= 0x01;
|
||||||
|
lcd_send(lcd, 0x04 | lcd->entrymode, false);
|
||||||
|
} // lcd_autoscroll()
|
||||||
|
|
||||||
|
// This will justify the text to the left from the cursor
|
||||||
|
void lcd_no_autoscroll(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||||
|
// Instruction: Entry mode set, clear shift = 0x01
|
||||||
|
lcd->entrymode &= ~0x01;
|
||||||
|
lcd_send(lcd, 0x04 | lcd->entrymode, false);
|
||||||
|
} // lcd_no_autoscroll()
|
||||||
|
|
||||||
|
// Setting the backlight: It can only be turn on or off.
|
||||||
|
// Current backlight value is saved in the i2c_lcd_pcf8574_handle_t struct for further data transfers
|
||||||
|
void lcd_set_backlight(i2c_lcd_pcf8574_handle_t* lcd, uint8_t brightness) {
|
||||||
|
// Place the backlight value in the lcd struct
|
||||||
|
lcd->backlight = brightness;
|
||||||
|
// Send no data
|
||||||
|
lcd_write_i2c(lcd, 0x00, true, false);
|
||||||
|
} // lcd_set_backlight()
|
||||||
|
|
||||||
|
// Custom character creation: allows us to create up to 8 custom characters in the CGRAM locations
|
||||||
|
void lcd_create_char(i2c_lcd_pcf8574_handle_t* lcd, uint8_t location, uint8_t charmap[]) {
|
||||||
|
location &= 0x7; // Only 8 locations are available
|
||||||
|
// Set the CGRAM address
|
||||||
|
lcd_send(lcd, 0x40 | (location << 3), false);
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
lcd_write(lcd, charmap[i]);
|
||||||
|
}
|
||||||
|
} // lcd_create_char()
|
||||||
|
|
||||||
|
// Write a byte to the LCD
|
||||||
|
void lcd_write(i2c_lcd_pcf8574_handle_t* lcd, uint8_t value) {
|
||||||
|
lcd_send(lcd, value, true);
|
||||||
|
} // lcd_write()
|
||||||
|
|
||||||
|
// Print characters to the LCD: cursor set or clear instruction must preceded this instruction, or it will write on the current text.
|
||||||
|
void lcd_print(i2c_lcd_pcf8574_handle_t* lcd, const char* str) {
|
||||||
|
while (*str) {
|
||||||
|
lcd_write(lcd, *str++);
|
||||||
|
}
|
||||||
|
} // lcd_print()
|
||||||
|
|
||||||
|
// Additional function to print numbers as formatted string
|
||||||
|
void lcd_print_number(i2c_lcd_pcf8574_handle_t* lcd, uint8_t col, uint8_t row, uint8_t buf_len, const char *str, ...) {
|
||||||
|
// Ensure the buffer length is greater than zero
|
||||||
|
if (buf_len == 0)
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "Buffer length must be greater than 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a buffer to hold the characters
|
||||||
|
char buffer[buf_len];
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, str);
|
||||||
|
|
||||||
|
int chars_written = vsniprintf(buffer, buf_len, str, args);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
if (chars_written < 0) {
|
||||||
|
ESP_LOGE(TAG, "Encoding error in vsnprintf");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((size_t)chars_written >= buf_len) {
|
||||||
|
ESP_LOGW(TAG, "Buffer overflow: %d characters needed, but only %d available", chars_written + 1, buf_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
lcd_set_cursor(lcd, col, row);
|
||||||
|
lcd_print(lcd, buffer);
|
||||||
|
|
||||||
|
} // lcd_print_number()
|
||||||
|
|
||||||
|
|
||||||
|
// Private functions: derived from the esp32 i2c_master driver
|
||||||
|
|
||||||
|
|
||||||
|
static void lcd_send(i2c_lcd_pcf8574_handle_t* lcd, uint8_t value, bool is_data) {
|
||||||
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
|
i2c_master_start(cmd);
|
||||||
|
i2c_master_write_byte(cmd, (lcd->i2c_addr << 1) | I2C_MASTER_WRITE, true);
|
||||||
|
lcd_write_nibble(lcd, (value >> 4 & 0x0F), is_data, cmd);
|
||||||
|
lcd_write_nibble(lcd, (value & 0x0F), is_data, cmd);
|
||||||
|
i2c_master_stop(cmd);
|
||||||
|
esp_err_t ret = i2c_master_cmd_begin(lcd->i2c_port, cmd, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||||
|
i2c_cmd_link_delete(cmd);
|
||||||
|
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Failed to send data to LCD: %s", esp_err_to_name(ret));
|
||||||
|
}
|
||||||
|
} // lcd_send()
|
||||||
|
|
||||||
|
// Write a nibble / half byte with ACK
|
||||||
|
static void lcd_write_nibble(i2c_lcd_pcf8574_handle_t* lcd, uint8_t half_byte, bool is_data, i2c_cmd_handle_t cmd) {
|
||||||
|
|
||||||
|
// Map the data to the given pin connections
|
||||||
|
uint8_t data = is_data ? lcd->rs_mask : 0;
|
||||||
|
|
||||||
|
// Don't use rw_mask here
|
||||||
|
if (lcd->backlight > 0) {
|
||||||
|
data |= lcd->backlight_mask;
|
||||||
|
}
|
||||||
|
// Allow arbitrary pin configuration
|
||||||
|
if (half_byte & 0x01) data |= lcd->data_mask[0];
|
||||||
|
if (half_byte & 0x02) data |= lcd->data_mask[1];
|
||||||
|
if (half_byte & 0x04) data |= lcd->data_mask[2];
|
||||||
|
if (half_byte & 0x08) data |= lcd->data_mask[3];
|
||||||
|
|
||||||
|
i2c_master_write_byte(cmd, data | lcd->enable_mask, true);
|
||||||
|
i2c_master_write_byte(cmd, data, true);
|
||||||
|
} // lcd_write_nibble()
|
||||||
|
|
||||||
|
// Private function to change the PCF8574 pins to the given value.
|
||||||
|
static void lcd_write_i2c(i2c_lcd_pcf8574_handle_t* lcd, uint8_t data, bool is_data, bool enable) {
|
||||||
|
if (is_data) {
|
||||||
|
data |= lcd->rs_mask;
|
||||||
|
}
|
||||||
|
if (enable) {
|
||||||
|
data |= lcd->enable_mask;
|
||||||
|
}
|
||||||
|
if (lcd->backlight > 0) {
|
||||||
|
data |= lcd->backlight_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
|
i2c_master_start(cmd);
|
||||||
|
i2c_master_write_byte(cmd, (lcd->i2c_addr << 1) | I2C_MASTER_WRITE, true);
|
||||||
|
i2c_master_write_byte(cmd, data, true);
|
||||||
|
i2c_master_stop(cmd);
|
||||||
|
esp_err_t ret = i2c_master_cmd_begin(lcd->i2c_port, cmd, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||||
|
i2c_cmd_link_delete(cmd);
|
||||||
|
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Failed to write to LCD: %s", esp_err_to_name(ret));
|
||||||
|
}
|
||||||
|
} // lcd_write_i2c()
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/// \file i2c_lcd_pcf8574.h
|
||||||
|
/// \brief Liquid Crystal display driver with PCF8574 adapter for esp-idf
|
||||||
|
///
|
||||||
|
/// \author Femi Olugbon, https://iamflinks.github.io
|
||||||
|
/// \copyright Copyright (c) 2024 by Femi Olugbon
|
||||||
|
///
|
||||||
|
/// The library work is lincensed under a BSD style license.
|
||||||
|
///
|
||||||
|
/// \details
|
||||||
|
/// This library can drive a LCD based on the Hitachi's HD44790 display chip that is wired through a PCF8574 I2C converter. It uses the esp-idf i2c_driver component for communication. The library was adapted from the LiquidCrystal_PCF8574 (Mathias Hertel) and LiquidCrystal_I2C Arduino libraries.
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// ChangeLog:
|
||||||
|
/// ===========
|
||||||
|
/// * 07/22/2024 --> Created
|
||||||
|
/// * 07/23/2024 --> Added number printing functionality
|
||||||
|
///
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef I2C_LCD_PCF8574_H
|
||||||
|
#define I2C_LCD_PCF8574_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "driver/i2c.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LCD_MAX_ROWS 4
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t i2c_addr;
|
||||||
|
uint8_t backlight;
|
||||||
|
uint8_t cols;
|
||||||
|
uint8_t lines;
|
||||||
|
uint8_t entrymode;
|
||||||
|
uint8_t displaycontrol;
|
||||||
|
uint8_t row_offsets[LCD_MAX_ROWS];
|
||||||
|
uint8_t rs_mask;
|
||||||
|
uint8_t rw_mask;
|
||||||
|
uint8_t enable_mask;
|
||||||
|
uint8_t backlight_mask;
|
||||||
|
uint8_t data_mask[4];
|
||||||
|
i2c_port_t i2c_port;
|
||||||
|
} i2c_lcd_pcf8574_handle_t;
|
||||||
|
|
||||||
|
|
||||||
|
// Initialize the LCD
|
||||||
|
void lcd_init(i2c_lcd_pcf8574_handle_t* lcd, uint8_t i2c_addr, i2c_port_t i2c_port);
|
||||||
|
|
||||||
|
// Begin using the LCD
|
||||||
|
void lcd_begin(i2c_lcd_pcf8574_handle_t* lcd, uint8_t cols, uint8_t rows);
|
||||||
|
|
||||||
|
// Clear the LCD
|
||||||
|
void lcd_clear(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
|
||||||
|
// Move cursor to home position
|
||||||
|
void lcd_home(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
|
||||||
|
// Set cursor position
|
||||||
|
void lcd_set_cursor(i2c_lcd_pcf8574_handle_t* lcd, uint8_t col, uint8_t row);
|
||||||
|
|
||||||
|
// Turn the display on/off
|
||||||
|
void lcd_no_display(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
void lcd_display(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
|
||||||
|
// Turn the cursor on/off
|
||||||
|
void lcd_cursor(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
void lcd_no_cursor(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
|
||||||
|
// Turn blinking cursor on/off
|
||||||
|
void lcd_blink(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
void lcd_no_blink(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
|
||||||
|
// Scroll the display
|
||||||
|
void lcd_scroll_display_left(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
void lcd_scroll_display_right(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
|
||||||
|
// Set the direction for text that flows automatically
|
||||||
|
void lcd_left_to_right(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
void lcd_right_to_left(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
|
||||||
|
// Turn on/off autoscroll
|
||||||
|
void lcd_autoscroll(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
void lcd_no_autoscroll(i2c_lcd_pcf8574_handle_t* lcd);
|
||||||
|
|
||||||
|
// Set backlight brightness
|
||||||
|
void lcd_set_backlight(i2c_lcd_pcf8574_handle_t* lcd, uint8_t brightness);
|
||||||
|
|
||||||
|
// Create a custom character
|
||||||
|
void lcd_create_char(i2c_lcd_pcf8574_handle_t* lcd, uint8_t location, uint8_t charmap[]);
|
||||||
|
|
||||||
|
// Write a character to the LCD
|
||||||
|
void lcd_write(i2c_lcd_pcf8574_handle_t* lcd, uint8_t value);
|
||||||
|
|
||||||
|
// Print a string to the LCD
|
||||||
|
void lcd_print(i2c_lcd_pcf8574_handle_t* lcd, const char* str);
|
||||||
|
|
||||||
|
void lcd_print_number(i2c_lcd_pcf8574_handle_t* lcd, uint8_t col, uint8_t row, uint8_t buf_len, const char *str, ...);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // C++ extern
|
||||||
|
|
||||||
|
#endif // I2C_LCD_PCF8574_H
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#include "power.h"
|
||||||
|
#include "char_lcd.h"
|
||||||
|
|
||||||
|
static const char* TAG = "POWER";
|
||||||
|
|
||||||
|
void bat_monitor_task(void* arg) {
|
||||||
|
while (1) {
|
||||||
|
char str_buf[33] = {0};
|
||||||
|
uint16_t voltage = lipo.voltage();
|
||||||
|
sprintf(str_buf, "%d.%03dV", voltage / 1000, voltage % 1000);
|
||||||
|
|
||||||
|
lcd_clear();
|
||||||
|
lcd_print(1, 0, str_buf);
|
||||||
|
|
||||||
|
int16_t current = lipo.current(current_measure::AVG);
|
||||||
|
sprintf(str_buf, "%dmA", current);
|
||||||
|
|
||||||
|
lcd_print(1, 1, str_buf);
|
||||||
|
|
||||||
|
|
||||||
|
int16_t total_cap = lipo.capacity(capacity_measure::FULL);
|
||||||
|
sprintf(str_buf, "%dmAh", total_cap);
|
||||||
|
|
||||||
|
lcd_print(1, 2, str_buf);
|
||||||
|
|
||||||
|
int16_t soc = lipo.soc(soc_measure::FILTERED);
|
||||||
|
sprintf(str_buf, "%d%%", soc);
|
||||||
|
|
||||||
|
lcd_print(1, 3, str_buf);
|
||||||
|
|
||||||
|
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(250));
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_power_board() {
|
||||||
|
if (!lipo.begin()) {
|
||||||
|
ESP_LOGE(TAG, "Failed to init communication with the battery gas guage");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto voltage = lipo.voltage();
|
||||||
|
ESP_LOGI(TAG, "Battery Voltage: %d", voltage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef POWER_H
|
||||||
|
#define POWER_H
|
||||||
|
|
||||||
|
#include "SparkFunBQ27441/SparkFunBQ27441.h"
|
||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
void bat_monitor_task(void* arg);
|
||||||
|
|
||||||
|
/// Initializes the battery gas guage for getting battery stats.
|
||||||
|
void init_power_board();
|
||||||
|
uint16_t get_bat_voltage();
|
||||||
|
|
||||||
|
#endif /* POWER_H */
|
||||||
+56
-44
@@ -1,74 +1,86 @@
|
|||||||
#include "sd.h"
|
#include "sd.h"
|
||||||
|
#include "char_lcd.h"
|
||||||
|
#include "bottom_half.h"
|
||||||
|
|
||||||
sdmmc_card_t *card;
|
sdmmc_card_t *card;
|
||||||
|
|
||||||
static const char* mount_point = MOUNT_POINT;
|
static const char* mount_point = MOUNT_POINT;
|
||||||
static const char* TAG = "sd";
|
static const char* TAG = "sd";
|
||||||
|
|
||||||
void init_sd() {
|
bool init_sd() {
|
||||||
|
ESP_LOGI(TAG, "Initializing SD card...");
|
||||||
|
|
||||||
esp_err_t ret;
|
esp_err_t ret;
|
||||||
|
|
||||||
// Options for mounting the filesystem.
|
|
||||||
// If format_if_mount_failed is set to true, SD card will be partitioned and
|
|
||||||
// formatted in case when mounting fails.
|
|
||||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||||
.format_if_mount_failed = false,
|
.format_if_mount_failed = false,
|
||||||
.max_files = 5,
|
.max_files = 8,
|
||||||
.allocation_unit_size = 16 * 1024,
|
.allocation_unit_size = 16 * 1024,
|
||||||
.disk_status_check_enable = false,
|
.disk_status_check_enable = true,
|
||||||
|
.use_one_fat = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Initializing SD card");
|
|
||||||
|
|
||||||
// Use settings defined above to initialize SD card and mount FAT filesystem.
|
|
||||||
// Note: esp_vfs_fat_sdmmc/sdspi_mount is all-in-one convenience functions.
|
|
||||||
// Please check its source code and implement error recovery when developing
|
|
||||||
// production applications.
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Using SDMMC peripheral");
|
ESP_LOGI(TAG, "Using SDMMC peripheral");
|
||||||
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
||||||
|
|
||||||
// This initializes the slot without card detect (CD) and write protect (WP) signals.
|
sdmmc_slot_config_t slot_config = {
|
||||||
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
|
.clk = SD_PIN_CLK,
|
||||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
.cmd = SD_PIN_CMD,
|
||||||
|
.d0 = SD_PIN_D0,
|
||||||
// Set bus width to use:
|
.d1 = SD_PIN_D1,
|
||||||
slot_config.width = 4;
|
.d2 = SD_PIN_D2,
|
||||||
|
.d3 = SD_PIN_D3,
|
||||||
// On chips where the GPIOs used for SD card can be configured, set them in
|
.d4 = GPIO_NUM_NC,
|
||||||
// the slot_config structure:
|
.d5 = GPIO_NUM_NC,
|
||||||
slot_config.clk = SD_PIN_CLK;
|
.d6 = GPIO_NUM_NC,
|
||||||
slot_config.cmd = SD_PIN_CMD;
|
.d7 = GPIO_NUM_NC,
|
||||||
slot_config.d0 = SD_PIN_D0;
|
.cd = GPIO_NUM_NC,
|
||||||
slot_config.d1 = SD_PIN_D1;
|
.wp = GPIO_NUM_NC,
|
||||||
slot_config.d2 = SD_PIN_D2;
|
.width = 4,
|
||||||
slot_config.d3 = SD_PIN_D3;
|
.flags = 0
|
||||||
|
// .flags = SDMMC_SLOT_FLAG_INTERNAL_PULLUP
|
||||||
// Enable internal pullups on enabled pins. The internal pullups
|
};
|
||||||
// are insufficient however, please make sure 10k external pullups are
|
|
||||||
// connected on the bus. This is for debug / example purpose only.
|
|
||||||
slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
|
|
||||||
|
|
||||||
|
try_mount:
|
||||||
ESP_LOGI(TAG, "Mounting filesystem");
|
ESP_LOGI(TAG, "Mounting filesystem");
|
||||||
ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
||||||
|
|
||||||
if (ret != ESP_OK) {
|
if (ret == ESP_OK) {
|
||||||
if (ret == ESP_FAIL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to mount filesystem. "
|
|
||||||
"If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option.");
|
|
||||||
} else {
|
|
||||||
ESP_LOGE(TAG, "Failed to initialize the card (%s). "
|
|
||||||
"Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ESP_LOGI(TAG, "Filesystem mounted");
|
ESP_LOGI(TAG, "Filesystem mounted");
|
||||||
|
} else {
|
||||||
|
ESP_LOGE(TAG, "Failed to mount sd card: %s.", esp_err_to_name(ret));
|
||||||
|
|
||||||
|
lcd_print(0, 0, "SD: ");
|
||||||
|
lcd_print(4, 0, esp_err_to_name(ret));
|
||||||
|
lcd_print(0, 1, "Press Green to retry");
|
||||||
|
lcd_print(0, 2, "Press Yellow to skip");
|
||||||
|
lcd_print(0, 3, "Press Red to format");
|
||||||
|
|
||||||
|
ButtonKey button;
|
||||||
|
while (!( get_button_pressed(&button) && (button == ButtonKey::button_green || button == ButtonKey::button_red || button == ButtonKey::button_yellow) )) vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
|
||||||
|
lcd_clear();
|
||||||
|
|
||||||
|
if (button == ButtonKey::button_green) {
|
||||||
|
goto try_mount;
|
||||||
|
}
|
||||||
|
if (button == ButtonKey::button_yellow) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (button == ButtonKey::button_red) {
|
||||||
|
mount_config.format_if_mount_failed = true;
|
||||||
|
goto try_mount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Card has been initialized, print its properties
|
// Card has been initialized, print its properties
|
||||||
sdmmc_card_print_info(stdout, card);
|
sdmmc_card_print_info(stdout, card);
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "SD card initialized!");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deinit_sd() {
|
void deinit_sd() {
|
||||||
esp_vfs_fat_sdcard_unmount(mount_point, card);
|
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_vfs_fat_sdcard_unmount(mount_point, card));
|
||||||
ESP_LOGI(TAG, "Card unmounted");
|
ESP_LOGI(TAG, "Card unmounted");
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -19,7 +19,11 @@ extern sdmmc_card_t *card;
|
|||||||
#define SD_PIN_D2 GPIO_NUM_39
|
#define SD_PIN_D2 GPIO_NUM_39
|
||||||
#define SD_PIN_D3 GPIO_NUM_38
|
#define SD_PIN_D3 GPIO_NUM_38
|
||||||
|
|
||||||
void init_sd();
|
/// @brief Initializes the SD card
|
||||||
|
///
|
||||||
|
/// This requires the char_lcd to have been initialized.
|
||||||
|
/// @return
|
||||||
|
bool init_sd();
|
||||||
void deinit_sd();
|
void deinit_sd();
|
||||||
|
|
||||||
#endif /* SD_H */
|
#endif /* SD_H */
|
||||||
@@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
i2s_chan_handle_t tx_chan;
|
i2s_chan_handle_t tx_chan;
|
||||||
|
|
||||||
static const char *TAG = "speaker_driver";
|
static const char *TAG = "speaker";
|
||||||
|
|
||||||
esp_err_t play_raw_stop_queue(const char *fp, QueueHandle_t stop_handle) {
|
esp_err_t play_raw_stop_queue(const char *fp, QueueHandle_t stop_handle) {
|
||||||
FILE *fh = fopen(fp, "rb");
|
FILE *fh = fopen(fp, "rb");
|
||||||
if (fh == NULL)
|
if (fh == NULL) {
|
||||||
{
|
|
||||||
ESP_LOGE(TAG, "Failed to open file");
|
ESP_LOGE(TAG, "Failed to open file");
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
@@ -61,7 +60,6 @@ esp_err_t play_raw_stop_queue(const char *fp, QueueHandle_t stop_handle) {
|
|||||||
esp_err_t play_raw(const char *fp) {
|
esp_err_t play_raw(const char *fp) {
|
||||||
FILE *fh = fopen(fp, "rb");
|
FILE *fh = fopen(fp, "rb");
|
||||||
if (fh == NULL)
|
if (fh == NULL)
|
||||||
{
|
|
||||||
ESP_LOGE(TAG, "Failed to open file");
|
ESP_LOGE(TAG, "Failed to open file");
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
@@ -109,6 +107,8 @@ esp_err_t play_raw(const char *fp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_speaker(void) {
|
void init_speaker(void) {
|
||||||
|
ESP_LOGI(TAG, "Initializing speaker...");
|
||||||
|
|
||||||
i2s_chan_config_t tx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
|
i2s_chan_config_t tx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
|
||||||
ESP_ERROR_CHECK(i2s_new_channel(&tx_chan_cfg, &tx_chan, NULL));
|
ESP_ERROR_CHECK(i2s_new_channel(&tx_chan_cfg, &tx_chan, NULL));
|
||||||
|
|
||||||
@@ -129,6 +129,8 @@ void init_speaker(void) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(i2s_channel_init_std_mode(tx_chan, &tx_std_cfg));
|
ESP_ERROR_CHECK(i2s_channel_init_std_mode(tx_chan, &tx_std_cfg));
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Speaker initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void play_example() {
|
void play_example() {
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ static void initialize_display() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const esp_lcd_panel_dev_config_t lcd_config = {
|
const esp_lcd_panel_dev_config_t lcd_config = {
|
||||||
.reset_gpio_num = TFT_PIN_RESET,
|
.reset_gpio_num = TFT_PIN_RESET,
|
||||||
.color_space = LCD_RGB_ELEMENT_ORDER_BGR,
|
.color_space = LCD_RGB_ELEMENT_ORDER_BGR,
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@
|
|||||||
#include <esp_lcd_panel_io.h>
|
#include <esp_lcd_panel_io.h>
|
||||||
#include <esp_lcd_panel_vendor.h>
|
#include <esp_lcd_panel_vendor.h>
|
||||||
#include <esp_lcd_panel_ops.h>
|
#include <esp_lcd_panel_ops.h>
|
||||||
#include <esp_lcd_ili9488.h>
|
#include "esp_lcd_ili9488/esp_lcd_ili9488.h"
|
||||||
#include <esp_timer.h>
|
#include <esp_timer.h>
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
|
|||||||
@@ -79,10 +79,9 @@ void clear_wires_pressed_released_cut(void) {
|
|||||||
button_released = false;
|
button_released = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void strike(char* reason) {
|
void strike(const char* reason) {
|
||||||
ESP_LOGW("strike!", "%s", reason);
|
ESP_LOGW("strike!", "%s", reason);
|
||||||
lcd_set_cursor(&lcd, 0, 3);
|
lcd_print(0, 3, reason);
|
||||||
lcd_print(&lcd, reason);
|
|
||||||
time_penalty(STRIKE_TIME_PENALTY);
|
time_penalty(STRIKE_TIME_PENALTY);
|
||||||
total_strikes += 1;
|
total_strikes += 1;
|
||||||
uint8_t reg = 6;
|
uint8_t reg = 6;
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ void clear_wires_pressed_released_cut(void);
|
|||||||
|
|
||||||
void set_leds(uint8_t led_states);
|
void set_leds(uint8_t led_states);
|
||||||
|
|
||||||
void strike(char* reason);
|
void strike(const char* reason);
|
||||||
|
|
||||||
#endif /* WIRES_HPP */
|
#endif /* WIRES_HPP */
|
||||||
+47
-23
@@ -1,5 +1,6 @@
|
|||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
|
||||||
|
// TODO: move to driver
|
||||||
void clean_bomb(void) {
|
void clean_bomb(void) {
|
||||||
// clear pending inputs
|
// clear pending inputs
|
||||||
clear_all_pressed_released();
|
clear_all_pressed_released();
|
||||||
@@ -16,23 +17,11 @@ void clean_bomb(void) {
|
|||||||
set_module_sseg_raw(clear);
|
set_module_sseg_raw(clear);
|
||||||
|
|
||||||
// clear char lcd
|
// clear char lcd
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
lcd_no_cursor(&lcd);
|
lcd_set_cursor_vis(false);
|
||||||
lcd_set_cursor(&lcd, 0, 0);
|
lcd_cursor_home();
|
||||||
}
|
}
|
||||||
|
|
||||||
void poster_child_task(void* arg) {
|
|
||||||
while (1) {
|
|
||||||
if (get_help_button_pressed()) {
|
|
||||||
play_raw(MOUNT_POINT "/poster.pcm");
|
|
||||||
}
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
|
||||||
}
|
|
||||||
|
|
||||||
vTaskDelete(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const int STRING_MAX_LEN = 8;
|
static const int STRING_MAX_LEN = 8;
|
||||||
void do_star_codes(StarCodeHandler* star_codes, int star_codes_len) {
|
void do_star_codes(StarCodeHandler* star_codes, int star_codes_len) {
|
||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
@@ -41,7 +30,7 @@ void do_star_codes(StarCodeHandler* star_codes, int star_codes_len) {
|
|||||||
char current[STRING_MAX_LEN+1] = {0};
|
char current[STRING_MAX_LEN+1] = {0};
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
while (get_pressed_keypad(&key)) {
|
while (get_keypad_pressed(&key)) {
|
||||||
if (key == KeypadKey::star) {
|
if (key == KeypadKey::star) {
|
||||||
current[0] = '*';
|
current[0] = '*';
|
||||||
for (int i = 1; i < STRING_MAX_LEN; i++) {
|
for (int i = 1; i < STRING_MAX_LEN; i++) {
|
||||||
@@ -59,8 +48,7 @@ void do_star_codes(StarCodeHandler* star_codes, int star_codes_len) {
|
|||||||
StarCodeHandler sch = star_codes[i];
|
StarCodeHandler sch = star_codes[i];
|
||||||
if (strcmp(current, sch.code) == 0) {
|
if (strcmp(current, sch.code) == 0) {
|
||||||
hit = true;
|
hit = true;
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
lcd_print(1, 2, sch.display_text);
|
||||||
lcd_print(&lcd, sch.display_text);
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(2000));
|
vTaskDelay(pdMS_TO_TICKS(2000));
|
||||||
if (sch.callback != nullptr) {
|
if (sch.callback != nullptr) {
|
||||||
(sch.callback)();
|
(sch.callback)();
|
||||||
@@ -73,8 +61,7 @@ void do_star_codes(StarCodeHandler* star_codes, int star_codes_len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hit) {
|
if (!hit) {
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
lcd_print(1, 2, "Invalid Star Code");
|
||||||
lcd_print(&lcd, "Invalid Star Code");
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(2000));
|
vTaskDelay(pdMS_TO_TICKS(2000));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,11 +81,48 @@ void do_star_codes(StarCodeHandler* star_codes, int star_codes_len) {
|
|||||||
}
|
}
|
||||||
// ESP_LOGI(STEP0_TAG, "Pressed: %c", c);
|
// ESP_LOGI(STEP0_TAG, "Pressed: %c", c);
|
||||||
|
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
lcd_print(1, 1, current);
|
||||||
lcd_print(&lcd, current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static lv_style_t game_results_style;
|
||||||
|
static lv_obj_t* game_results_label;
|
||||||
|
|
||||||
|
static char str_buf[10] = {0};
|
||||||
|
static char* write_time(uint32_t game_time) {
|
||||||
|
uint8_t hours = (game_time / (1000*60*60)) % 10;
|
||||||
|
uint8_t minutes = (game_time / (1000*60)) % 60;
|
||||||
|
uint8_t seconds = (game_time / (1000)) % 60;
|
||||||
|
|
||||||
|
sprintf(str_buf, "%d:%02d:%02d", hours, minutes, seconds);
|
||||||
|
return str_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern uint32_t initial_game_time;
|
||||||
|
void display_game_results(void) {
|
||||||
|
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
||||||
|
lv_style_init(&game_results_style);
|
||||||
|
lv_style_set_text_color(&game_results_style, lv_color_white());
|
||||||
|
lv_style_set_bg_color(&game_results_style, lv_color_black());
|
||||||
|
lv_style_set_bg_opa(&game_results_style, LV_OPA_100);
|
||||||
|
lv_style_set_text_align(&game_results_style, LV_TEXT_ALIGN_CENTER);
|
||||||
|
|
||||||
|
game_results_label = lv_label_create(lv_scr_act());
|
||||||
|
lv_obj_align(game_results_label, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
lv_obj_add_style(game_results_label, &game_results_style, LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
char buf[100] = {0};
|
||||||
|
int32_t time_s = get_game_time();
|
||||||
|
int32_t time_spent = initial_game_time - time_s;
|
||||||
|
char* time = write_time(time_spent);
|
||||||
|
sprintf(buf, "Finished!\nTotal Time (w/ penalties): %s\nTotal Strikes: %ld", time, total_strikes);
|
||||||
|
|
||||||
|
lv_label_set_text(game_results_label, buf);
|
||||||
|
|
||||||
|
xSemaphoreGive(xGuiSemaphore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+4
-2
@@ -8,10 +8,11 @@
|
|||||||
#include "drivers/char_lcd.h"
|
#include "drivers/char_lcd.h"
|
||||||
#include "drivers/leds.h"
|
#include "drivers/leds.h"
|
||||||
#include "drivers/speaker.h"
|
#include "drivers/speaker.h"
|
||||||
|
#include "drivers/tft.h"
|
||||||
|
|
||||||
struct StarCodeHandler {
|
struct StarCodeHandler {
|
||||||
char* code;
|
const char* code;
|
||||||
char* display_text;
|
const char* display_text;
|
||||||
bool should_exit;
|
bool should_exit;
|
||||||
void (*callback)(void);
|
void (*callback)(void);
|
||||||
};
|
};
|
||||||
@@ -23,5 +24,6 @@ struct StarCodeHandler {
|
|||||||
void clean_bomb(void);
|
void clean_bomb(void);
|
||||||
void poster_child_task(void* arg);
|
void poster_child_task(void* arg);
|
||||||
void do_star_codes(StarCodeHandler* star_codes, int star_codes_len);
|
void do_star_codes(StarCodeHandler* star_codes, int star_codes_len);
|
||||||
|
void display_game_results();
|
||||||
|
|
||||||
#endif /* HELPER_H */
|
#endif /* HELPER_H */
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ dependencies:
|
|||||||
# iamflinks/i2c_lcd_pcf8574: "^1.0.1"
|
# iamflinks/i2c_lcd_pcf8574: "^1.0.1"
|
||||||
espressif/led_strip: "^2.5.4"
|
espressif/led_strip: "^2.5.4"
|
||||||
lvgl/lvgl: "^8.1"
|
lvgl/lvgl: "^8.1"
|
||||||
atanisoft/esp_lcd_ili9488: "^1.0.9"
|
# atanisoft/esp_lcd_ili9488: "^1.0.9"
|
||||||
## Required IDF version
|
## Required IDF version
|
||||||
idf:
|
idf:
|
||||||
version: ">=4.1.0"
|
version: ">=4.1.0"
|
||||||
|
|||||||
+7
-50
@@ -2,17 +2,9 @@
|
|||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "driver/uart.h"
|
|
||||||
#include "driver/i2c.h"
|
|
||||||
#include "drivers/tft.h"
|
|
||||||
#include "drivers/wires.h"
|
|
||||||
#include "drivers/bottom_half.h"
|
|
||||||
#include "drivers/sd.h"
|
|
||||||
#include "drivers/game_timer.h"
|
|
||||||
#include "drivers/speaker.h"
|
|
||||||
#include "drivers/char_lcd.h"
|
|
||||||
#include "esp_rom_gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
#include "drivers/leds.h"
|
|
||||||
|
#include "drivers/all.h"
|
||||||
|
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
|
||||||
@@ -25,56 +17,19 @@
|
|||||||
#include "steps/step6.h"
|
#include "steps/step6.h"
|
||||||
|
|
||||||
static const char *TAG = "main";
|
static const char *TAG = "main";
|
||||||
uint32_t initial_game_time = 60*60*1000;
|
uint32_t initial_game_time = 90*60*1000;
|
||||||
uint32_t skip_to_step = 0;
|
uint32_t skip_to_step = 0;
|
||||||
|
|
||||||
static void print_bin(char* out_str, uint8_t n) {
|
|
||||||
out_str[0] = ((n & 0b1000) ? '1' : '0');
|
|
||||||
out_str[1] = ((n & 0b0100) ? '1' : '0');
|
|
||||||
out_str[2] = ((n & 0b0010) ? '1' : '0');
|
|
||||||
out_str[3] = ((n & 0b0001) ? '1' : '0');
|
|
||||||
}
|
|
||||||
|
|
||||||
static void debug_switches() {
|
|
||||||
uint8_t switch_state = 0;
|
|
||||||
uint8_t button_state = 0;
|
|
||||||
|
|
||||||
char buff[5] = {0};
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
uint8_t new_button_state = get_button_state();
|
|
||||||
if (new_button_state != button_state) {
|
|
||||||
button_state = new_button_state;
|
|
||||||
print_bin(buff, button_state);
|
|
||||||
ESP_LOGI("main", "b: 0b%s", buff);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t new_switch_state = get_switch_state();
|
|
||||||
if (new_switch_state != switch_state) {
|
|
||||||
switch_state = new_switch_state;
|
|
||||||
print_bin(buff, switch_state);
|
|
||||||
ESP_LOGI("main", "s: 0b%s", buff);
|
|
||||||
}
|
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void app_main(void) {
|
extern "C" void app_main(void) {
|
||||||
printf("app_main\n");
|
printf("app_main\n");
|
||||||
|
|
||||||
init_sd();
|
init_drivers();
|
||||||
init_tft();
|
init_tft();
|
||||||
init_speaker();
|
|
||||||
init_sseg();
|
init_sseg();
|
||||||
init_game_module_timer();
|
init_game_module_timer();
|
||||||
init_leds();
|
init_leds();
|
||||||
init_wires();
|
init_wires();
|
||||||
|
init_power_board();
|
||||||
init_bottom_half();
|
|
||||||
init_char_lcd();
|
|
||||||
|
|
||||||
// debug_switches();
|
|
||||||
|
|
||||||
clean_bomb();
|
clean_bomb();
|
||||||
step0();
|
step0();
|
||||||
@@ -97,5 +52,7 @@ extern "C" void app_main(void) {
|
|||||||
stop_game_timer();
|
stop_game_timer();
|
||||||
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(play_raw("/sdcard/diffused.pcm"));
|
ESP_ERROR_CHECK_WITHOUT_ABORT(play_raw("/sdcard/diffused.pcm"));
|
||||||
|
|
||||||
|
display_game_results();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,13 @@ void print_wires(WireColor* wires, int editing_idx) {
|
|||||||
bool cut[NUM_WIRES];
|
bool cut[NUM_WIRES];
|
||||||
solve_wires(wires, cut);
|
solve_wires(wires, cut);
|
||||||
|
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
|
||||||
char string_buf[NUM_WIRES+1] = {0};
|
char string_buf[NUM_WIRES+1] = {0};
|
||||||
wires_to_string(wires, string_buf);
|
wires_to_string(wires, string_buf);
|
||||||
lcd_print(&lcd, string_buf);
|
lcd_print(1, 1, string_buf);
|
||||||
|
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
|
||||||
cut_to_string(cut, string_buf);
|
cut_to_string(cut, string_buf);
|
||||||
lcd_print(&lcd, string_buf);
|
lcd_print(1, 2, string_buf);
|
||||||
|
|
||||||
lcd_set_cursor(&lcd, 1, 3);
|
|
||||||
wires_state = get_wires();
|
wires_state = get_wires();
|
||||||
for (int i = 0; i < NUM_WIRES; i++) {
|
for (int i = 0; i < NUM_WIRES; i++) {
|
||||||
if (wires_state & (1<<i)) {
|
if (wires_state & (1<<i)) {
|
||||||
@@ -24,16 +21,16 @@ void print_wires(WireColor* wires, int editing_idx) {
|
|||||||
string_buf[i] = '!';
|
string_buf[i] = '!';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lcd_print(&lcd, string_buf);
|
lcd_print(1, 3, string_buf);
|
||||||
|
|
||||||
lcd_set_cursor(&lcd, editing_idx+1, 1);
|
lcd_set_cursor_pos(editing_idx+1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_wires(void) {
|
void setup_wires(void) {
|
||||||
clear_all_pressed_released();
|
clear_all_pressed_released();
|
||||||
get_cut_wires();
|
get_cut_wires();
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
lcd_cursor(&lcd);
|
lcd_set_cursor_vis(false);
|
||||||
|
|
||||||
WireColor wires[NUM_WIRES];
|
WireColor wires[NUM_WIRES];
|
||||||
load_wires_from_sd_card(wires);
|
load_wires_from_sd_card(wires);
|
||||||
@@ -45,18 +42,18 @@ void setup_wires(void) {
|
|||||||
ButtonKey button;
|
ButtonKey button;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
while (get_pressed_keypad(&key)) {
|
while (get_keypad_pressed(&key)) {
|
||||||
if (key == KeypadKey::k1) {
|
if (key == KeypadKey::k1) {
|
||||||
generate_new_wires(wires);
|
generate_new_wires(wires);
|
||||||
save_wires_to_sd_card(wires);
|
save_wires_to_sd_card(wires);
|
||||||
print_wires(wires, editing_idx);
|
print_wires(wires, editing_idx);
|
||||||
} else if (key == KeypadKey::pound) {
|
} else if (key == KeypadKey::pound) {
|
||||||
lcd_no_cursor(&lcd);
|
lcd_set_cursor_vis(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (get_pressed_button(&button)) {
|
while (get_button_pressed(&button)) {
|
||||||
if (button == ButtonKey::b1) {
|
if (button == ButtonKey::b1) {
|
||||||
// left
|
// left
|
||||||
editing_idx = editing_idx - 1;
|
editing_idx = editing_idx - 1;
|
||||||
|
|||||||
+171
-42
@@ -19,9 +19,24 @@ static void try_step4(void) { clean_bomb(); step4(); }
|
|||||||
static void try_step5(void) { clean_bomb(); step5(); }
|
static void try_step5(void) { clean_bomb(); step5(); }
|
||||||
static void try_step6(void) { clean_bomb(); step6(); }
|
static void try_step6(void) { clean_bomb(); step6(); }
|
||||||
static void issue_strike(void) { strike("Strike Issued"); }
|
static void issue_strike(void) { strike("Strike Issued"); }
|
||||||
|
static void debug_switches(void);
|
||||||
|
static void battery_stats(void) {
|
||||||
|
BaseType_t xReturned;
|
||||||
|
TaskHandle_t xHandle = NULL;
|
||||||
|
xReturned = xTaskCreate(bat_monitor_task, "bat_monitor", 4096, NULL, 5, &xHandle);
|
||||||
|
|
||||||
|
KeypadKey k;
|
||||||
|
while (!get_keypad_pressed(&k) || k != KeypadKey::pound) vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
|
||||||
|
if (xReturned == pdPASS) {
|
||||||
|
vTaskDelete(xHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Wait for "*9819"
|
/// Wait for "*9819"
|
||||||
void step0(void) {
|
void step0(void) {
|
||||||
|
led_strip_set_pixel(leds, Led::speaker, 0, 0, 20);
|
||||||
|
led_strip_refresh(leds);
|
||||||
StarCodeHandler star_codes[] = {
|
StarCodeHandler star_codes[] = {
|
||||||
{
|
{
|
||||||
.code = "*9819",
|
.code = "*9819",
|
||||||
@@ -41,6 +56,18 @@ void step0(void) {
|
|||||||
.should_exit = false,
|
.should_exit = false,
|
||||||
.callback = set_game_time,
|
.callback = set_game_time,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.code = "*59863",
|
||||||
|
.display_text = "Debug Switches",
|
||||||
|
.should_exit = false,
|
||||||
|
.callback = debug_switches,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.code = "*59864",
|
||||||
|
.display_text = "Battery Stats",
|
||||||
|
.should_exit = false,
|
||||||
|
.callback = battery_stats,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.code = "*59871",
|
.code = "*59871",
|
||||||
.display_text = "Try Step 1",
|
.display_text = "Try Step 1",
|
||||||
@@ -124,54 +151,59 @@ void step0(void) {
|
|||||||
do_star_codes(star_codes, len);
|
do_star_codes(star_codes, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* SECONDS_OR_MINUTES[] = {
|
|
||||||
"Minutes",
|
|
||||||
"Seconds",
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int STRING_MAX_LEN = 8;
|
static const int CURSOR_POS_MAP[5] = {1, 3, 4, 6, 7};
|
||||||
|
static char str_buf[18] = {0};
|
||||||
|
static void _update_display(uint8_t* digits, uint8_t cursor_pos) {
|
||||||
|
sprintf(str_buf, "%d:%d%d:%d%d", digits[0], digits[1], digits[2], digits[3], digits[4]);
|
||||||
|
lcd_clear();
|
||||||
|
lcd_print(1, 1, str_buf);
|
||||||
|
cursor_pos = MAX(0, MIN(4, cursor_pos));
|
||||||
|
int mapped_cursor_pos = CURSOR_POS_MAP[cursor_pos];
|
||||||
|
lcd_set_cursor_pos(mapped_cursor_pos, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void set_game_time(void) {
|
static void set_game_time(void) {
|
||||||
|
uint8_t hours = (initial_game_time / (1000*60*60)) % 10;
|
||||||
|
uint8_t minutes = (initial_game_time / (1000*60)) % 60;
|
||||||
|
uint8_t seconds = (initial_game_time / (1000)) % 60;
|
||||||
|
uint8_t digits[5] = {hours, (uint8_t)(minutes / 10), (uint8_t)(minutes % 10), (uint8_t)(seconds / 10), (uint8_t)(seconds % 10)};
|
||||||
|
uint8_t cursor_pos = 0;
|
||||||
|
lcd_set_cursor_vis(true);
|
||||||
|
|
||||||
|
_update_display(digits, cursor_pos);
|
||||||
|
|
||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
bool seconds = true;
|
ButtonKey button;
|
||||||
|
|
||||||
int current = initial_game_time / 1000;
|
|
||||||
char str_buf[21] = {0};
|
|
||||||
|
|
||||||
lcd_clear(&lcd);
|
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
|
||||||
sprintf(str_buf, "%d", current);
|
|
||||||
lcd_print(&lcd, str_buf);
|
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
|
||||||
lcd_print(&lcd, SECONDS_OR_MINUTES[seconds]);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
while (get_pressed_keypad(&key)) {
|
while (get_keypad_pressed(&key)) {
|
||||||
if (key == KeypadKey::star) {
|
if (key == KeypadKey::star) {
|
||||||
current = 0;
|
digits[0] = 0;
|
||||||
|
digits[1] = 0;
|
||||||
|
digits[2] = 0;
|
||||||
|
digits[3] = 0;
|
||||||
|
digits[4] = 0;
|
||||||
|
cursor_pos = 0;
|
||||||
} else if (key == KeypadKey::pound) {
|
} else if (key == KeypadKey::pound) {
|
||||||
// submit
|
// submit
|
||||||
if (current == 0) {
|
if (digits[0] != 0 || digits[1] != 0 || digits[2] != 0 || digits[3] != 0 || digits[4] != 0) {
|
||||||
clean_bomb();
|
uint32_t new_game_time = 0;
|
||||||
return;
|
new_game_time += digits[0] * (1000*60*60);
|
||||||
|
new_game_time += (digits[1] * 10 + digits[2]) * (1000*60);
|
||||||
|
new_game_time += (digits[3] * 10 + digits[4]) * (1000);
|
||||||
|
initial_game_time = new_game_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seconds) {
|
|
||||||
initial_game_time = current * 1000;
|
|
||||||
} else {
|
|
||||||
initial_game_time = current * 60*1000;
|
|
||||||
}
|
|
||||||
clean_bomb();
|
clean_bomb();
|
||||||
|
led_strip_set_pixel(leds, Led::speaker, 0, 0, 20);
|
||||||
|
led_strip_refresh(leds);
|
||||||
return;
|
return;
|
||||||
} else if (key == KeypadKey::ka) {
|
|
||||||
if (seconds) {
|
|
||||||
current = current / 60;
|
|
||||||
} else {
|
} else {
|
||||||
current = current * 60;
|
int just_pressed = -1;
|
||||||
}
|
|
||||||
seconds = !seconds;
|
|
||||||
} else {
|
|
||||||
int just_pressed = 0;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case KeypadKey::k0:
|
||||||
|
just_pressed = 0;
|
||||||
|
break;
|
||||||
case KeypadKey::k1:
|
case KeypadKey::k1:
|
||||||
just_pressed = 1;
|
just_pressed = 1;
|
||||||
break;
|
break;
|
||||||
@@ -203,17 +235,114 @@ static void set_game_time(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = (current * 10) + just_pressed;
|
if (just_pressed != -1) {
|
||||||
|
digits[cursor_pos] = just_pressed;
|
||||||
|
cursor_pos = MIN(4, cursor_pos+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_clear(&lcd);
|
_update_display(digits, cursor_pos);
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
}
|
||||||
sprintf(str_buf, "%d", current);
|
|
||||||
lcd_print(&lcd, str_buf);
|
while (get_button_pressed(&button)) {
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
if (button == ButtonKey::b1) {
|
||||||
lcd_print(&lcd, SECONDS_OR_MINUTES[seconds]);
|
cursor_pos = MAX(0, cursor_pos-1);
|
||||||
|
} else if (button == ButtonKey::b2) {
|
||||||
|
cursor_pos = MIN(4, cursor_pos+1);
|
||||||
|
}
|
||||||
|
_update_display(digits, cursor_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void print_4bin_rev(char* out_str, uint8_t n) {
|
||||||
|
out_str[0] = ((n & 0b0001) ? '1' : '0');
|
||||||
|
out_str[1] = ((n & 0b0010) ? '1' : '0');
|
||||||
|
out_str[2] = ((n & 0b0100) ? '1' : '0');
|
||||||
|
out_str[3] = ((n & 0b1000) ? '1' : '0');
|
||||||
|
out_str[4] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
static void debug_switches(void) {
|
||||||
|
clean_bomb();
|
||||||
|
uint8_t switch_state = 0xFF;
|
||||||
|
uint8_t switch_touch_state = 0xFF;
|
||||||
|
uint8_t button_state = 0xFF;
|
||||||
|
|
||||||
|
char bin_buf[5] = {0};
|
||||||
|
char buf[21] = {0};
|
||||||
|
|
||||||
|
KeypadKey key;
|
||||||
|
ButtonKey button;
|
||||||
|
SwitchKey switch_;
|
||||||
|
while (1) {
|
||||||
|
if (get_button_pressed(&button)) {
|
||||||
|
sprintf(buf, "Button Pressed: %d ", button);
|
||||||
|
lcd_print(0, 3, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
if (get_button_released(&button)) {
|
||||||
|
sprintf(buf, "Button Released: %d", button);
|
||||||
|
lcd_print(0, 3, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
if (get_switch_flipped_down(&switch_)) {
|
||||||
|
sprintf(buf, "Switch Down: %d ", switch_);
|
||||||
|
lcd_print(0, 3, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
if (get_switch_flipped_up(&switch_)) {
|
||||||
|
sprintf(buf, "Switch Up: %d ", switch_);
|
||||||
|
lcd_print(0, 3, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
if (get_switch_touch_pressed(&switch_)) {
|
||||||
|
sprintf(buf, "Switch Touch: %d ", switch_);
|
||||||
|
lcd_print(0, 3, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
if (get_switch_touch_released(&switch_)) {
|
||||||
|
sprintf(buf, "Switch Un-touch: %d", switch_);
|
||||||
|
lcd_print(0, 3, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t new_switch_touch_state = get_switch_touch_state();
|
||||||
|
if (new_switch_touch_state != switch_touch_state) {
|
||||||
|
switch_touch_state = new_switch_touch_state;
|
||||||
|
print_4bin_rev(bin_buf, switch_touch_state);
|
||||||
|
sprintf(buf, "t: %s", bin_buf);
|
||||||
|
lcd_print(1, 0, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t new_switch_state = get_switch_state();
|
||||||
|
if (new_switch_state != switch_state) {
|
||||||
|
switch_state = new_switch_state;
|
||||||
|
print_4bin_rev(bin_buf, switch_state);
|
||||||
|
sprintf(buf, "s: %s", bin_buf);
|
||||||
|
lcd_print(1, 1, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t new_button_state = get_button_state();
|
||||||
|
if (new_button_state != button_state) {
|
||||||
|
button_state = new_button_state;
|
||||||
|
print_4bin_rev(bin_buf, button_state);
|
||||||
|
sprintf(buf, "b: %s", bin_buf);
|
||||||
|
lcd_print(1, 2, buf);
|
||||||
|
ESP_LOGI(TAG, "%s", buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (get_keypad_pressed(&key) && key == KeypadKey::pound) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../drivers/bottom_half.h"
|
#include "../drivers/bottom_half.h"
|
||||||
#include "../drivers/char_lcd.h"
|
#include "../drivers/char_lcd.h"
|
||||||
#include "../drivers/wires.h"
|
#include "../drivers/wires.h"
|
||||||
|
#include "../drivers/power.h"
|
||||||
#include "setup_wires.h"
|
#include "setup_wires.h"
|
||||||
#include "../helper.h"
|
#include "../helper.h"
|
||||||
|
|
||||||
|
|||||||
+19
-26
@@ -1,15 +1,16 @@
|
|||||||
#include "step1.h"
|
#include "step1.h"
|
||||||
|
|
||||||
|
__attribute__((unused))
|
||||||
static const char *TAG = "step1";
|
static const char *TAG = "step1";
|
||||||
|
|
||||||
static char* COLOR_NAMES[] = {
|
static const char* COLOR_NAMES[] = {
|
||||||
"green",
|
"green",
|
||||||
"red",
|
"red",
|
||||||
"yellow",
|
"yellow",
|
||||||
"blue"
|
"blue"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char* NUM_NAMES[] = {
|
static const char* NUM_NAMES[] = {
|
||||||
"one",
|
"one",
|
||||||
"two",
|
"two",
|
||||||
"three",
|
"three",
|
||||||
@@ -66,9 +67,9 @@ static void init_step(void) {
|
|||||||
lv_obj_add_style(lv_scr_act(), &style_screen, LV_STATE_DEFAULT);
|
lv_obj_add_style(lv_scr_act(), &style_screen, LV_STATE_DEFAULT);
|
||||||
|
|
||||||
// rgb565
|
// rgb565
|
||||||
lv_color_t green = { .full = 0x0640 };
|
lv_color_t green = { .full = 0x0560 };
|
||||||
lv_color_t red = { .full = 0xf800 };
|
lv_color_t red = { .full = 0xf800 };
|
||||||
lv_color_t yellow = { .full = 0xfe80 };
|
lv_color_t yellow = { .full = 0xfce0 };
|
||||||
lv_color_t blue = { .full = 0x045f };
|
lv_color_t blue = { .full = 0x045f };
|
||||||
|
|
||||||
lv_style_init(&green_text);
|
lv_style_init(&green_text);
|
||||||
@@ -119,23 +120,16 @@ static void generate_switch_leds(void) {
|
|||||||
led_strip_refresh(leds);
|
led_strip_refresh(leds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_text_and_color(char* text_str, int color) {
|
static void set_text_and_color(const char* text_str, int color) {
|
||||||
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
||||||
ESP_LOGI(TAG, "set_text_and_color: setting text: %s", text_str);
|
|
||||||
lv_label_set_text(text, text_str);
|
lv_label_set_text(text, text_str);
|
||||||
ESP_LOGI(TAG, "set_text_and_color: set text");
|
|
||||||
lv_obj_center(text);
|
lv_obj_center(text);
|
||||||
ESP_LOGI(TAG, "set_text_and_color: setting %d", color);
|
|
||||||
if (last_style != nullptr) {
|
if (last_style != nullptr) {
|
||||||
ESP_LOGI(TAG, "set_text_and_color: removing %d", color);
|
|
||||||
lv_obj_remove_style(text, last_style, LV_STATE_DEFAULT);
|
lv_obj_remove_style(text, last_style, LV_STATE_DEFAULT);
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "set_text_and_color: adding %d", color);
|
|
||||||
lv_obj_add_style(text, color_styles[color], LV_STATE_DEFAULT);
|
lv_obj_add_style(text, color_styles[color], LV_STATE_DEFAULT);
|
||||||
last_style = color_styles[color];
|
last_style = color_styles[color];
|
||||||
ESP_LOGI(TAG, "set_text_and_color: style");
|
|
||||||
xSemaphoreGive(xGuiSemaphore);
|
xSemaphoreGive(xGuiSemaphore);
|
||||||
ESP_LOGI(TAG, "set_text_and_color: give");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +137,7 @@ static int generate_part_a(void) {
|
|||||||
int text_color = zero_to_three(my_gen);
|
int text_color = zero_to_three(my_gen);
|
||||||
int text_idx = zero_to_three(my_gen);
|
int text_idx = zero_to_three(my_gen);
|
||||||
|
|
||||||
char* text_string = COLOR_NAMES[text_idx];
|
const char* text_string = COLOR_NAMES[text_idx];
|
||||||
|
|
||||||
set_text_and_color(text_string, text_color);
|
set_text_and_color(text_string, text_color);
|
||||||
generate_switch_leds();
|
generate_switch_leds();
|
||||||
@@ -161,7 +155,7 @@ static int generate_part_b(void) {
|
|||||||
int text_color = zero_to_three(my_gen);
|
int text_color = zero_to_three(my_gen);
|
||||||
int text_number = zero_to_three(my_gen);
|
int text_number = zero_to_three(my_gen);
|
||||||
|
|
||||||
char* text_string = NUM_NAMES[text_number];
|
const char* text_string = NUM_NAMES[text_number];
|
||||||
|
|
||||||
set_text_and_color(text_string, text_color);
|
set_text_and_color(text_string, text_color);
|
||||||
generate_switch_leds();
|
generate_switch_leds();
|
||||||
@@ -177,7 +171,7 @@ static int generate_part_c(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int text_color = zero_to_three(my_gen);
|
int text_color = zero_to_three(my_gen);
|
||||||
char* text_string = "switch";
|
const char* text_string = "switch";
|
||||||
|
|
||||||
set_text_and_color(text_string, text_color);
|
set_text_and_color(text_string, text_color);
|
||||||
generate_switch_leds();
|
generate_switch_leds();
|
||||||
@@ -200,29 +194,28 @@ static int generate_part(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void update_lcd_count(int times) {
|
static void update_lcd_count(int times) {
|
||||||
char buf[6] = {0};
|
char buf[16] = {0};
|
||||||
sprintf(buf, "%d/15", times);
|
sprintf(buf, "%d/15", times);
|
||||||
lcd_set_cursor(&lcd, 14, 1);
|
lcd_print(14, 1, buf);
|
||||||
lcd_print(&lcd, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool play_part(uint32_t time) {
|
static bool play_part(uint32_t time) {
|
||||||
stop_module_timer();
|
stop_module_timer();
|
||||||
set_module_time(time);
|
set_module_time(time);
|
||||||
|
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
lcd_set_cursor_pos(1, 1);
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case 0:
|
case 0:
|
||||||
lcd_print(&lcd, "COLOR");
|
lcd_print("COLOR");
|
||||||
led_strip_set_pixel(leds, Led::char_lcd, 20, 0, 20);
|
led_strip_set_pixel(leds, Led::char_lcd, 20, 0, 20);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
lcd_print(&lcd, "NUMBER");
|
lcd_print("NUMBER");
|
||||||
led_strip_set_pixel(leds, Led::char_lcd, 0, 0, 30);
|
led_strip_set_pixel(leds, Led::char_lcd, 0, 0, 30);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
lcd_print(&lcd, "SWITCH");
|
lcd_print("SWITCH");
|
||||||
led_strip_set_pixel(leds, Led::char_lcd, 20, 20, 0);
|
led_strip_set_pixel(leds, Led::char_lcd, 20, 20, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -236,7 +229,7 @@ static bool play_part(uint32_t time) {
|
|||||||
SwitchKey switch_;
|
SwitchKey switch_;
|
||||||
|
|
||||||
while (times < 15) {
|
while (times < 15) {
|
||||||
while (get_pressed_button(&button)) {
|
while (get_button_pressed(&button)) {
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
if ((int)(button) == correct) {
|
if ((int)(button) == correct) {
|
||||||
times++;
|
times++;
|
||||||
@@ -247,7 +240,7 @@ static bool play_part(uint32_t time) {
|
|||||||
strike("Incorrect action");
|
strike("Incorrect action");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (get_flipped_switch(&switch_)) {
|
while (get_switch_flipped(&switch_)) {
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
if (switch_leds[(int)(switch_)] + 4 == correct) {
|
if (switch_leds[(int)(switch_)] + 4 == correct) {
|
||||||
times++;
|
times++;
|
||||||
@@ -276,7 +269,7 @@ static bool play_part(uint32_t time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void step1(void) {
|
void step1(void) {
|
||||||
while (get_flipped_switch(nullptr));
|
while (get_switch_flipped(nullptr));
|
||||||
|
|
||||||
init_step();
|
init_step();
|
||||||
while (!play_part(40*1000));
|
while (!play_part(40*1000));
|
||||||
|
|||||||
+11
-10
@@ -1,7 +1,10 @@
|
|||||||
#include "step2.h"
|
#include "step2.h"
|
||||||
|
|
||||||
|
__attribute__((unused))
|
||||||
static const char *TAG = "step2";
|
static const char *TAG = "step2";
|
||||||
|
|
||||||
|
static const int NUM_SOLVES = 4;
|
||||||
|
|
||||||
// one: 0b00000110
|
// one: 0b00000110
|
||||||
// seven: 0b00000111
|
// seven: 0b00000111
|
||||||
static const uint8_t SSEG_NUMS[8] = {0b00111111, 0b01011011, 0b01001111, 0b01100110, 0b01101101, 0b01111101, 0b01111111, 0b01101111};
|
static const uint8_t SSEG_NUMS[8] = {0b00111111, 0b01011011, 0b01001111, 0b01100110, 0b01101101, 0b01111101, 0b01111111, 0b01101111};
|
||||||
@@ -88,19 +91,18 @@ void step2(void) {
|
|||||||
int solved_times = 0;
|
int solved_times = 0;
|
||||||
|
|
||||||
new_puzzle();
|
new_puzzle();
|
||||||
int strike_time = xTaskGetTickCount();
|
int strike_time = 0;
|
||||||
bool striked = false;
|
while(solved_times < NUM_SOLVES) {
|
||||||
while(solved_times < 4) {
|
|
||||||
// for every bit in the answer-
|
// for every bit in the answer-
|
||||||
set_module_sseg_raw(display_map);
|
set_module_sseg_raw(display_map);
|
||||||
if (get_pressed_keypad(&key)) {
|
if (get_keypad_pressed(&key)) {
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
char c = char_of_keypad_key(key);
|
char c = char_of_keypad_key(key);
|
||||||
// ESP_LOGI(TAG, "Pressed: %c", c);
|
// ESP_LOGI(TAG, "Pressed: %c", c);
|
||||||
if (c == answer_char) {
|
if (c == answer_char) {
|
||||||
play_raw(MOUNT_POINT "/correct.pcm");
|
play_raw(MOUNT_POINT "/correct.pcm");
|
||||||
solved_times++;
|
solved_times++;
|
||||||
if (solved_times < 3) {
|
if (solved_times < NUM_SOLVES) {
|
||||||
clean_bomb();
|
clean_bomb();
|
||||||
new_puzzle();
|
new_puzzle();
|
||||||
} else {
|
} else {
|
||||||
@@ -109,14 +111,13 @@ void step2(void) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
strike_time = xTaskGetTickCount();
|
strike_time = xTaskGetTickCount();
|
||||||
striked = true;
|
|
||||||
strike("Incorrect Character!");
|
strike("Incorrect Character!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xTaskGetTickCount() - strike_time > pdMS_TO_TICKS(5000)) {
|
if (strike_time != 0 && xTaskGetTickCount() - strike_time > pdMS_TO_TICKS(5000)) {
|
||||||
striked = false;
|
strike_time = 0;
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
}
|
}
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-17
@@ -4,6 +4,9 @@
|
|||||||
#define THREE_SECOND_TIME 90'000
|
#define THREE_SECOND_TIME 90'000
|
||||||
#define SIX_SECOND_TIME 75'000
|
#define SIX_SECOND_TIME 75'000
|
||||||
|
|
||||||
|
#define TIMES_TO_COMPLETE 4
|
||||||
|
|
||||||
|
__attribute__((unused))
|
||||||
static const char *TAG = "step3";
|
static const char *TAG = "step3";
|
||||||
|
|
||||||
static int tone = 0;
|
static int tone = 0;
|
||||||
@@ -32,7 +35,7 @@ static const char* LCD_STRINGS[] = {
|
|||||||
static int indicator_led_idxs[LED_COUNT] = {0};
|
static int indicator_led_idxs[LED_COUNT] = {0};
|
||||||
|
|
||||||
static bool contains_coconut = false;
|
static bool contains_coconut = false;
|
||||||
static char* COCONUT = "coconut";
|
static const char* COCONUT = "coconut";
|
||||||
static char lcd_random_char_set[] = "aeiou tnsrhldm";
|
static char lcd_random_char_set[] = "aeiou tnsrhldm";
|
||||||
static char random_lcd_text[21] = {0};
|
static char random_lcd_text[21] = {0};
|
||||||
|
|
||||||
@@ -72,10 +75,10 @@ void step3(void) {
|
|||||||
int len = sizeof(star_codes)/sizeof(StarCodeHandler);
|
int len = sizeof(star_codes)/sizeof(StarCodeHandler);
|
||||||
do_star_codes(star_codes, len);
|
do_star_codes(star_codes, len);
|
||||||
|
|
||||||
while (times < 4) {
|
while (times < TIMES_TO_COMPLETE) {
|
||||||
tone = tone_dist(gen);
|
tone = tone_dist(gen);
|
||||||
// tone = 2;
|
// tone = 2;
|
||||||
while (get_pressed_button(nullptr)) vTaskDelay(pdMS_TO_TICKS(10));
|
while (get_button_pressed(nullptr)) vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
|
||||||
play_raw(MOUNT_POINT "/que.pcm");
|
play_raw(MOUNT_POINT "/que.pcm");
|
||||||
play_raw(TONE_FILES[tone]);
|
play_raw(TONE_FILES[tone]);
|
||||||
@@ -146,7 +149,7 @@ static uint8_t four_bit_flag(bool b0, bool b1, bool b2, bool b3) {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_bin(char* out_str, uint8_t n) {
|
static void print_4bin(char* out_str, uint8_t n) {
|
||||||
out_str[0] = ((n & 0b1000) ? '1' : '0');
|
out_str[0] = ((n & 0b1000) ? '1' : '0');
|
||||||
out_str[1] = ((n & 0b0100) ? '1' : '0');
|
out_str[1] = ((n & 0b0100) ? '1' : '0');
|
||||||
out_str[2] = ((n & 0b0010) ? '1' : '0');
|
out_str[2] = ((n & 0b0010) ? '1' : '0');
|
||||||
@@ -170,19 +173,19 @@ static void print_bin(char* out_str, uint8_t n) {
|
|||||||
|
|
||||||
static void debug_correct_values(uint8_t correct_buttons, uint8_t button_mask, uint8_t correct_switches) {
|
static void debug_correct_values(uint8_t correct_buttons, uint8_t button_mask, uint8_t correct_switches) {
|
||||||
char buf[20] = {0};
|
char buf[20] = {0};
|
||||||
print_bin(buf, correct_switches);
|
print_4bin(buf, correct_switches);
|
||||||
ESP_LOGI(TAG, "Expected Switch State: 0b%s", buf);
|
ESP_LOGI(TAG, "Expected Switch State: 0b%s", buf);
|
||||||
print_bin(buf, correct_buttons);
|
print_4bin(buf, correct_buttons);
|
||||||
ESP_LOGI(TAG, "Expected Button State: 0b%s", buf);
|
ESP_LOGI(TAG, "Expected Button State: 0b%s", buf);
|
||||||
print_bin(buf, button_mask);
|
print_4bin(buf, button_mask);
|
||||||
ESP_LOGI(TAG, "Button Mask: 0b%s", buf);
|
ESP_LOGI(TAG, "Button Mask: 0b%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void debug_actual_values(uint8_t buttons, uint8_t switch_) {
|
static void debug_actual_values(uint8_t buttons, uint8_t switch_) {
|
||||||
char buf[20] = {0};
|
char buf[20] = {0};
|
||||||
print_bin(buf, switch_);
|
print_4bin(buf, switch_);
|
||||||
ESP_LOGI(TAG, "Actual Switch State: 0b%s", buf);
|
ESP_LOGI(TAG, "Actual Switch State: 0b%s", buf);
|
||||||
print_bin(buf, buttons);
|
print_4bin(buf, buttons);
|
||||||
ESP_LOGI(TAG, "Actual Button State: 0b%s", buf);
|
ESP_LOGI(TAG, "Actual Button State: 0b%s", buf);
|
||||||
ESP_LOGI(TAG, "");
|
ESP_LOGI(TAG, "");
|
||||||
}
|
}
|
||||||
@@ -190,7 +193,7 @@ static void debug_actual_values(uint8_t buttons, uint8_t switch_) {
|
|||||||
static void wait_for_timer(void) {
|
static void wait_for_timer(void) {
|
||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
while (get_module_time() > 0) {
|
while (get_module_time() > 0) {
|
||||||
if (get_pressed_keypad(&key) && key == KeypadKey::kd) {
|
if (get_keypad_pressed(&key) && key == KeypadKey::kd) {
|
||||||
set_module_time(0);
|
set_module_time(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -208,9 +211,8 @@ static bool one_second() {
|
|||||||
int lcd_string_idx = lcd_string_dist(gen);
|
int lcd_string_idx = lcd_string_dist(gen);
|
||||||
bool was_high = (tone / 3) == 1;
|
bool was_high = (tone / 3) == 1;
|
||||||
write_leds();
|
write_leds();
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
lcd_print(1, 1, LCD_STRINGS[lcd_string_idx]);
|
||||||
lcd_print(&lcd, LCD_STRINGS[lcd_string_idx]);
|
|
||||||
|
|
||||||
int red_led_count = 0;
|
int red_led_count = 0;
|
||||||
int blue_led_count = 0;
|
int blue_led_count = 0;
|
||||||
@@ -265,8 +267,7 @@ static bool three_second() {
|
|||||||
int lcd_number = lcd_number_dist(gen);
|
int lcd_number = lcd_number_dist(gen);
|
||||||
char lcd_number_string[9] = {0};
|
char lcd_number_string[9] = {0};
|
||||||
sprintf(lcd_number_string, "%d", lcd_number);
|
sprintf(lcd_number_string, "%d", lcd_number);
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
lcd_print(1, 1, lcd_number_string);
|
||||||
lcd_print(&lcd, lcd_number_string);
|
|
||||||
|
|
||||||
bool was_high = (tone / 3) == 1;
|
bool was_high = (tone / 3) == 1;
|
||||||
|
|
||||||
@@ -328,8 +329,7 @@ static bool six_second() {
|
|||||||
|
|
||||||
generate_random_lcd_text();
|
generate_random_lcd_text();
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
lcd_set_cursor(&lcd, 0, 0);
|
lcd_print(0, 0, random_lcd_text);
|
||||||
lcd_print(&lcd, random_lcd_text);
|
|
||||||
|
|
||||||
int vowels = 0;
|
int vowels = 0;
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
|
|||||||
+13
-20
@@ -1,9 +1,8 @@
|
|||||||
#include "step4.h"
|
#include "step4.h"
|
||||||
|
|
||||||
|
__attribute__((unused))
|
||||||
static const char *TAG = "step4";
|
static const char *TAG = "step4";
|
||||||
|
|
||||||
static lv_obj_t* scr;
|
|
||||||
static lv_style_t scr_style;
|
|
||||||
static lv_obj_t* img;
|
static lv_obj_t* img;
|
||||||
|
|
||||||
static bool invisible_blocks = false;
|
static bool invisible_blocks = false;
|
||||||
@@ -13,7 +12,7 @@ static const int height = 22;
|
|||||||
static const int width = 10;
|
static const int width = 10;
|
||||||
|
|
||||||
static int board[height][width] = {0};
|
static int board[height][width] = {0};
|
||||||
static lv_obj_t* visual_board[height][width] = {0};
|
// static lv_obj_t* visual_board[height][width] = {0};
|
||||||
|
|
||||||
static lv_obj_t* line_clear_img;
|
static lv_obj_t* line_clear_img;
|
||||||
static lv_style_t game_over_style;
|
static lv_style_t game_over_style;
|
||||||
@@ -86,10 +85,6 @@ static int bccb(int i) { // [0,1,2,3] -> [ 0,+1,+1, 0]
|
|||||||
const int map[] = {0, 1, 1, 0};
|
const int map[] = {0, 1, 1, 0};
|
||||||
return map[i];
|
return map[i];
|
||||||
}
|
}
|
||||||
static int cbbc(int i) { // [0,1,2,3] -> [+1, 0, 0,+1]
|
|
||||||
const int map[] = {1, 0, 0, 1};
|
|
||||||
return map[i];
|
|
||||||
}
|
|
||||||
static int ccbb(int i) { // [0,1,2,3] -> [+1,+1, 0, 0]
|
static int ccbb(int i) { // [0,1,2,3] -> [+1,+1, 0, 0]
|
||||||
const int map[] = {1, 1, 0, 0};
|
const int map[] = {1, 1, 0, 0};
|
||||||
return map[i];
|
return map[i];
|
||||||
@@ -211,7 +206,7 @@ bool play_game(int time, int required_score) {
|
|||||||
show_board();
|
show_board();
|
||||||
|
|
||||||
ButtonKey button;
|
ButtonKey button;
|
||||||
while (get_pressed_button(&button));
|
while (get_button_pressed(&button));
|
||||||
// SwitchKey switch_;
|
// SwitchKey switch_;
|
||||||
|
|
||||||
const TickType_t first_repeat_time = pdMS_TO_TICKS(700);
|
const TickType_t first_repeat_time = pdMS_TO_TICKS(700);
|
||||||
@@ -220,7 +215,7 @@ bool play_game(int time, int required_score) {
|
|||||||
TickType_t last_repeat = 0;
|
TickType_t last_repeat = 0;
|
||||||
|
|
||||||
while(game) {
|
while(game) {
|
||||||
if (get_pressed_button(&button)) {
|
while (get_button_pressed(&button)) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case ButtonKey::b1:
|
case ButtonKey::b1:
|
||||||
move_left();
|
move_left();
|
||||||
@@ -245,7 +240,7 @@ bool play_game(int time, int required_score) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (get_released_button(&button)) {
|
while (get_button_released(&button)) {
|
||||||
if (button == ButtonKey::b3) {
|
if (button == ButtonKey::b3) {
|
||||||
down_held = 0;
|
down_held = 0;
|
||||||
}
|
}
|
||||||
@@ -274,7 +269,7 @@ bool play_game(int time, int required_score) {
|
|||||||
strike("Out of time");
|
strike("Out of time");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if (get_flipped_switch(&switch_)) {
|
// if (get_switch_flipped(&switch_)) {
|
||||||
// printf("%d\n", piece);
|
// printf("%d\n", piece);
|
||||||
// for (int i = 0; i < sizeof(piece_nodes)/sizeof(piece_nodes[0]); i++) {
|
// for (int i = 0; i < sizeof(piece_nodes)/sizeof(piece_nodes[0]); i++) {
|
||||||
// int* p = piece_nodes[i];
|
// int* p = piece_nodes[i];
|
||||||
@@ -300,9 +295,9 @@ static void complete(void) {
|
|||||||
xSemaphoreGive(xGuiSemaphore);
|
xSemaphoreGive(xGuiSemaphore);
|
||||||
}
|
}
|
||||||
vTaskDelay(pdMS_TO_TICKS(500));
|
vTaskDelay(pdMS_TO_TICKS(500));
|
||||||
while (get_pressed_button(nullptr));
|
while (get_button_pressed(nullptr));
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_button(nullptr)) break;
|
if (get_button_pressed(nullptr)) break;
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
}
|
}
|
||||||
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
||||||
@@ -318,9 +313,9 @@ static void fail(void) {
|
|||||||
xSemaphoreGive(xGuiSemaphore);
|
xSemaphoreGive(xGuiSemaphore);
|
||||||
}
|
}
|
||||||
vTaskDelay(pdMS_TO_TICKS(500));
|
vTaskDelay(pdMS_TO_TICKS(500));
|
||||||
while (get_pressed_button(nullptr));
|
while (get_button_pressed(nullptr));
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_button(nullptr)) break;
|
if (get_button_pressed(nullptr)) break;
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
}
|
}
|
||||||
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
||||||
@@ -343,7 +338,7 @@ void step4(void) {
|
|||||||
complete();
|
complete();
|
||||||
while (!play_game(4*60*1000, 4)) fail();
|
while (!play_game(4*60*1000, 4)) fail();
|
||||||
complete();
|
complete();
|
||||||
while (!play_game(6*60*1000, 8)) fail();
|
while (!play_game(7*60*1000, 8)) fail();
|
||||||
complete();
|
complete();
|
||||||
// vTaskDelay(pdMS_TO_TICKS(3000));
|
// vTaskDelay(pdMS_TO_TICKS(3000));
|
||||||
|
|
||||||
@@ -566,7 +561,6 @@ static void place_piece(void) {
|
|||||||
}
|
}
|
||||||
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
||||||
for (int i = 0; i < sizeof(piece_nodes)/sizeof(piece_nodes[0]); i++) {
|
for (int i = 0; i < sizeof(piece_nodes)/sizeof(piece_nodes[0]); i++) {
|
||||||
int* p = piece_nodes[i];
|
|
||||||
lv_obj_align(piece_imgs[i], LV_ALIGN_BOTTOM_LEFT, 159, -(height*16));
|
lv_obj_align(piece_imgs[i], LV_ALIGN_BOTTOM_LEFT, 159, -(height*16));
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xGuiSemaphore);
|
xSemaphoreGive(xGuiSemaphore);
|
||||||
@@ -663,9 +657,8 @@ static void check_line_clears(void) {
|
|||||||
static void update_score(void) {
|
static void update_score(void) {
|
||||||
char buff[16] = {};
|
char buff[16] = {};
|
||||||
sprintf(buff, "%d/%d", score, target_score);
|
sprintf(buff, "%d/%d", score, target_score);
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
lcd_print(1, 1, buff);
|
||||||
lcd_print(&lcd, buff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void line_clear(int hi) {
|
static void line_clear(int hi) {
|
||||||
|
|||||||
+52
-54
@@ -1,5 +1,16 @@
|
|||||||
#include "step5.h"
|
#include "step5.h"
|
||||||
|
|
||||||
|
#define TIME_CLEAR 30'000
|
||||||
|
#define TIME_PLANK 40'000
|
||||||
|
#define TIME_EMPTY 40'000
|
||||||
|
#define TIME_NOTHING 25'000
|
||||||
|
#define TIME_BLINK 35'000
|
||||||
|
#define TIME_UMMM 35'000
|
||||||
|
#define TIME_BLANK 40'000
|
||||||
|
#define TIME_WHAT 60'000
|
||||||
|
#define TIME_PLINK 40'000
|
||||||
|
|
||||||
|
__attribute__((unused))
|
||||||
static const char *TAG = "step5";
|
static const char *TAG = "step5";
|
||||||
|
|
||||||
static const int TIMES_TO_SOLVE = 9;
|
static const int TIMES_TO_SOLVE = 9;
|
||||||
@@ -206,7 +217,7 @@ void step5(void) {
|
|||||||
clean_bomb();
|
clean_bomb();
|
||||||
int solved_puzzles = 0;
|
int solved_puzzles = 0;
|
||||||
while (solved_puzzles < TIMES_TO_SOLVE) {
|
while (solved_puzzles < TIMES_TO_SOLVE) {
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
lcd_set_cursor_pos(1, 1);
|
||||||
bool solved_correctly = false;
|
bool solved_correctly = false;
|
||||||
|
|
||||||
int puzzle = puzzle_dist(gen);
|
int puzzle = puzzle_dist(gen);
|
||||||
@@ -214,8 +225,8 @@ void step5(void) {
|
|||||||
|
|
||||||
switch (puzzle) {
|
switch (puzzle) {
|
||||||
case 0: {
|
case 0: {
|
||||||
lcd_print(&lcd, "Clear");
|
lcd_print("Clear");
|
||||||
set_module_time(30000);
|
set_module_time(TIME_CLEAR);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
std::vector<int> indicator_options = all_leds;
|
std::vector<int> indicator_options = all_leds;
|
||||||
@@ -237,7 +248,7 @@ void step5(void) {
|
|||||||
// wait for submit
|
// wait for submit
|
||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_module_time() <= 0 || (get_pressed_keypad(&key) && (char_of_keypad_key(key) == '#'))) {
|
if (get_module_time() <= 0 || (get_keypad_pressed(&key) && (char_of_keypad_key(key) == '#'))) {
|
||||||
solved_correctly = submit_0(green_indicators);
|
solved_correctly = submit_0(green_indicators);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -247,8 +258,8 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
lcd_print(&lcd, "Blank");
|
lcd_print("Blank");
|
||||||
set_module_time(40000);
|
set_module_time(TIME_BLANK);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
std::uniform_int_distribution<> on_indicators_dist(16, 21);
|
std::uniform_int_distribution<> on_indicators_dist(16, 21);
|
||||||
@@ -267,7 +278,7 @@ void step5(void) {
|
|||||||
|
|
||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_keypad(&key)) {
|
if (get_keypad_pressed(&key)) {
|
||||||
char keypad_char = char_of_keypad_key(key);
|
char keypad_char = char_of_keypad_key(key);
|
||||||
if (keypad_char == '#') {
|
if (keypad_char == '#') {
|
||||||
solved_correctly = submit_1(indicators_num, pressed_keys, starting_switch_state);
|
solved_correctly = submit_1(indicators_num, pressed_keys, starting_switch_state);
|
||||||
@@ -285,7 +296,7 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
set_module_time(40000);
|
set_module_time(TIME_EMPTY);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
std::map<int, int> idx_to_led_map = {
|
std::map<int, int> idx_to_led_map = {
|
||||||
@@ -318,7 +329,7 @@ void step5(void) {
|
|||||||
ButtonKey button;
|
ButtonKey button;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_button(&button)) {
|
if (get_button_pressed(&button)) {
|
||||||
uint8_t button_state = get_button_state();
|
uint8_t button_state = get_button_state();
|
||||||
|
|
||||||
if ((button_state & 0b1) == 0b1) {
|
if ((button_state & 0b1) == 0b1) {
|
||||||
@@ -344,7 +355,7 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (get_pressed_keypad(&key)) {
|
if (get_keypad_pressed(&key)) {
|
||||||
char keypad_char = char_of_keypad_key(key);
|
char keypad_char = char_of_keypad_key(key);
|
||||||
if (keypad_char == '#') {
|
if (keypad_char == '#') {
|
||||||
solved_correctly = submit_2(lit_leds, green_button_pressed, blue_button_pressed, fingerprint_sensor_pressed, keypad_string);
|
solved_correctly = submit_2(lit_leds, green_button_pressed, blue_button_pressed, fingerprint_sensor_pressed, keypad_string);
|
||||||
@@ -364,8 +375,8 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
lcd_print(&lcd, "Nothing");
|
lcd_print("Nothing");
|
||||||
set_module_time(25000);
|
set_module_time(TIME_NOTHING);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
const int COLOR_RED[5] = {0, 20, 10, 0};
|
const int COLOR_RED[5] = {0, 20, 10, 0};
|
||||||
@@ -386,10 +397,8 @@ void step5(void) {
|
|||||||
int buttons_pressed = 0;
|
int buttons_pressed = 0;
|
||||||
|
|
||||||
ButtonKey button;
|
ButtonKey button;
|
||||||
KeypadKey key;
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_button(&button)) {
|
if (get_button_pressed(&button)) {
|
||||||
buttons_pressed++;
|
buttons_pressed++;
|
||||||
uint8_t button_state = get_button_state();
|
uint8_t button_state = get_button_state();
|
||||||
|
|
||||||
@@ -422,8 +431,8 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
lcd_print(&lcd, "Blink");
|
lcd_print("Blink");
|
||||||
set_module_time(35000);
|
set_module_time(TIME_BLINK);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
@@ -457,7 +466,7 @@ void step5(void) {
|
|||||||
uint8_t starting_switch_state = get_switch_state();
|
uint8_t starting_switch_state = get_switch_state();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_button(&button)) {
|
if (get_button_pressed(&button)) {
|
||||||
uint8_t button_state = get_button_state();
|
uint8_t button_state = get_button_state();
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
@@ -472,7 +481,7 @@ void step5(void) {
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||||
}
|
}
|
||||||
if (get_module_time() <= 0 || (get_pressed_keypad(&key) && (char_of_keypad_key(key) == '#'))) {
|
if (get_module_time() <= 0 || (get_keypad_pressed(&key) && (char_of_keypad_key(key) == '#'))) {
|
||||||
solved_correctly = submit_4(button_colors, switch_colors, starting_switch_state);
|
solved_correctly = submit_4(button_colors, switch_colors, starting_switch_state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -481,8 +490,8 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5: {
|
case 5: {
|
||||||
lcd_print(&lcd, "Ummm");
|
lcd_print("Ummm");
|
||||||
set_module_time(35000);
|
set_module_time(TIME_UMMM);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
std::uniform_int_distribution<> indicator_number_dist(0, 5);
|
std::uniform_int_distribution<> indicator_number_dist(0, 5);
|
||||||
@@ -505,7 +514,7 @@ void step5(void) {
|
|||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_button(&button)) {
|
if (get_button_pressed(&button)) {
|
||||||
uint8_t button_state = get_button_state();
|
uint8_t button_state = get_button_state();
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
|
||||||
@@ -523,7 +532,7 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (get_module_time() <= 0 || (get_pressed_keypad(&key) && (char_of_keypad_key(key) == '#'))) {
|
if (get_module_time() <= 0 || (get_keypad_pressed(&key) && (char_of_keypad_key(key) == '#'))) {
|
||||||
ESP_LOGI(TAG, "Keypad Char: %c, time: %lu", char_of_keypad_key(key), get_module_time());
|
ESP_LOGI(TAG, "Keypad Char: %c, time: %lu", char_of_keypad_key(key), get_module_time());
|
||||||
solved_correctly = submit_5(indicator_numbers, buttons_pressed);
|
solved_correctly = submit_5(indicator_numbers, buttons_pressed);
|
||||||
break;
|
break;
|
||||||
@@ -534,8 +543,8 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 6: {
|
case 6: {
|
||||||
lcd_print(&lcd, "Plank");
|
lcd_print("Plank");
|
||||||
set_module_time(40000);
|
set_module_time(TIME_PLANK);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
std::uniform_int_distribution<> led_color_dist(0, 5);
|
std::uniform_int_distribution<> led_color_dist(0, 5);
|
||||||
@@ -571,7 +580,7 @@ void step5(void) {
|
|||||||
|
|
||||||
std::uniform_int_distribution<> led_turn_on_dist(0, 3);
|
std::uniform_int_distribution<> led_turn_on_dist(0, 3);
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_button(&button)) {
|
if (get_button_pressed(&button)) {
|
||||||
uint8_t button_state = get_button_state();
|
uint8_t button_state = get_button_state();
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
|
||||||
@@ -614,8 +623,7 @@ void step5(void) {
|
|||||||
|
|
||||||
lastCycleTime = xTaskGetTickCount();
|
lastCycleTime = xTaskGetTickCount();
|
||||||
}
|
}
|
||||||
get_pressed_keypad(&key);
|
if (get_module_time() <= 0 || (get_keypad_pressed(&key) && (char_of_keypad_key(key) == '#'))) {
|
||||||
if (get_module_time() <= 0 || (get_pressed_keypad(&key) && (char_of_keypad_key(key) == '#'))) {
|
|
||||||
solved_correctly = submit_6(buttons_cycling, button_turned_on, led_off);
|
solved_correctly = submit_6(buttons_cycling, button_turned_on, led_off);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -624,8 +632,8 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 7: {
|
case 7: {
|
||||||
lcd_print(&lcd, "What");
|
lcd_print("What");
|
||||||
set_module_time(55000);
|
set_module_time(TIME_WHAT);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
std::uniform_int_distribution<> math_number_dist(1, 9);
|
std::uniform_int_distribution<> math_number_dist(1, 9);
|
||||||
@@ -697,8 +705,7 @@ void step5(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// display expression
|
// display expression
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
lcd_print(1, 2, display_expression.c_str());
|
||||||
lcd_print(&lcd, display_expression.c_str());
|
|
||||||
|
|
||||||
// set LEDs
|
// set LEDs
|
||||||
|
|
||||||
@@ -740,7 +747,7 @@ void step5(void) {
|
|||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_keypad(&key)) {
|
if (get_keypad_pressed(&key)) {
|
||||||
if (key == KeypadKey::star) {
|
if (key == KeypadKey::star) {
|
||||||
// clear
|
// clear
|
||||||
entered_string = "";
|
entered_string = "";
|
||||||
@@ -748,7 +755,6 @@ void step5(void) {
|
|||||||
// submit
|
// submit
|
||||||
if (entered_string != answer_string) {
|
if (entered_string != answer_string) {
|
||||||
strike("Incorrect answer!");
|
strike("Incorrect answer!");
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
solved_correctly = true;
|
solved_correctly = true;
|
||||||
}
|
}
|
||||||
@@ -757,28 +763,24 @@ void step5(void) {
|
|||||||
entered_string += char_of_keypad_key(key);
|
entered_string += char_of_keypad_key(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
lcd_print(1, 1, "What");
|
||||||
lcd_print(&lcd, "What");
|
lcd_print(1, 2, display_expression.c_str());
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
lcd_print(1, 3, entered_string.c_str());
|
||||||
lcd_print(&lcd, display_expression.c_str());
|
|
||||||
lcd_set_cursor(&lcd, 1, 3);
|
|
||||||
lcd_print(&lcd, entered_string.c_str());
|
|
||||||
}
|
}
|
||||||
if (get_module_time() <= 0) {
|
if (get_module_time() <= 0) {
|
||||||
strike("Ran out of time!");
|
strike("Ran out of time!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 8: {
|
case 8: {
|
||||||
lcd_print(&lcd, "Plink");
|
lcd_print("Plink");
|
||||||
set_module_time(40000);
|
set_module_time(TIME_PLINK);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
std::uniform_int_distribution<> indicator_number_dist(0, 4);
|
std::uniform_int_distribution<> indicator_number_dist(0, 4);
|
||||||
@@ -820,14 +822,13 @@ void step5(void) {
|
|||||||
|
|
||||||
// ESP_LOGI(TAG, "color string: %s", color_string.c_str());
|
// ESP_LOGI(TAG, "color string: %s", color_string.c_str());
|
||||||
|
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
lcd_print(1, 2, color_string.c_str());
|
||||||
lcd_print(&lcd, color_string.c_str());
|
|
||||||
|
|
||||||
std::string entered_string;
|
std::string entered_string;
|
||||||
|
|
||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (get_pressed_keypad(&key)) {
|
if (get_keypad_pressed(&key)) {
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
|
||||||
if (key == KeypadKey::star) {
|
if (key == KeypadKey::star) {
|
||||||
@@ -850,13 +851,10 @@ void step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_clear(&lcd);
|
lcd_clear();
|
||||||
lcd_set_cursor(&lcd, 1, 1);
|
lcd_print(1, 1, "Plink");
|
||||||
lcd_print(&lcd, "Plink");
|
lcd_print(1, 2, color_string.c_str());
|
||||||
lcd_set_cursor(&lcd, 1, 2);
|
lcd_print(1, 3, entered_string.c_str());
|
||||||
lcd_print(&lcd, color_string.c_str());
|
|
||||||
lcd_set_cursor(&lcd, 1, 3);
|
|
||||||
lcd_print(&lcd, entered_string.c_str());
|
|
||||||
}
|
}
|
||||||
if (get_module_time() <= 0) {
|
if (get_module_time() <= 0) {
|
||||||
strike("Ran out of time!");
|
strike("Ran out of time!");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "step6.h"
|
#include "step6.h"
|
||||||
|
|
||||||
|
__attribute__((unused))
|
||||||
static const char *TAG = "step6";
|
static const char *TAG = "step6";
|
||||||
|
|
||||||
static uint8_t cut_wires = 0;
|
static uint8_t cut_wires = 0;
|
||||||
@@ -14,7 +15,6 @@ void step6(void) {
|
|||||||
solve_wires(wires, solution);
|
solve_wires(wires, solution);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
uint8_t new_cut_wires = get_cut_wires();
|
uint8_t new_cut_wires = get_cut_wires();
|
||||||
uint8_t just_cut_wires = new_cut_wires & ~cut_wires;
|
uint8_t just_cut_wires = new_cut_wires & ~cut_wires;
|
||||||
cut_wires |= new_cut_wires;
|
cut_wires |= new_cut_wires;
|
||||||
|
|||||||
+111
-55
@@ -17,22 +17,22 @@ static int max(int n0, int n1, int n2, int n3, int n4, int n5);
|
|||||||
void wires_to_string(WireColor* wires, char* out_wires_string) {
|
void wires_to_string(WireColor* wires, char* out_wires_string) {
|
||||||
for (int i = 0; i < NUM_WIRES; i++) {
|
for (int i = 0; i < NUM_WIRES; i++) {
|
||||||
switch (wires[i]) {
|
switch (wires[i]) {
|
||||||
case WireColor::red:
|
case WireColor::wire_red:
|
||||||
out_wires_string[i] = 'r';
|
out_wires_string[i] = 'r';
|
||||||
break;
|
break;
|
||||||
case WireColor::yellow:
|
case WireColor::wire_yellow:
|
||||||
out_wires_string[i] = 'y';
|
out_wires_string[i] = 'y';
|
||||||
break;
|
break;
|
||||||
case WireColor::green:
|
case WireColor::wire_green:
|
||||||
out_wires_string[i] = 'g';
|
out_wires_string[i] = 'g';
|
||||||
break;
|
break;
|
||||||
case WireColor::blue:
|
case WireColor::wire_blue:
|
||||||
out_wires_string[i] = 'b';
|
out_wires_string[i] = 'b';
|
||||||
break;
|
break;
|
||||||
case WireColor::black:
|
case WireColor::wire_black:
|
||||||
out_wires_string[i] = 'k';
|
out_wires_string[i] = 'k';
|
||||||
break;
|
break;
|
||||||
case WireColor::white:
|
case WireColor::wire_white:
|
||||||
out_wires_string[i] = 'w';
|
out_wires_string[i] = 'w';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -52,22 +52,22 @@ void string_to_wires(char* wires_string, WireColor* out_wires) {
|
|||||||
for (int i = 0; i < NUM_WIRES; i++) {
|
for (int i = 0; i < NUM_WIRES; i++) {
|
||||||
switch (wires_string[i]) {
|
switch (wires_string[i]) {
|
||||||
case 'r':
|
case 'r':
|
||||||
out_wires[i] = WireColor::red;
|
out_wires[i] = WireColor::wire_red;
|
||||||
break;
|
break;
|
||||||
case 'y':
|
case 'y':
|
||||||
out_wires[i] = WireColor::yellow;
|
out_wires[i] = WireColor::wire_yellow;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
out_wires[i] = WireColor::green;
|
out_wires[i] = WireColor::wire_green;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
out_wires[i] = WireColor::blue;
|
out_wires[i] = WireColor::wire_blue;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
out_wires[i] = WireColor::black;
|
out_wires[i] = WireColor::wire_black;
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
out_wires[i] = WireColor::white;
|
out_wires[i] = WireColor::wire_white;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,6 +122,8 @@ void generate_new_wires(WireColor* wires) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void solve_wires(WireColor* wires, bool* out_cut) {
|
void solve_wires(WireColor* wires, bool* out_cut) {
|
||||||
|
bool debug = false;
|
||||||
|
|
||||||
// by default, don't cut any wires
|
// by default, don't cut any wires
|
||||||
for (int i = 0; i < NUM_WIRES; i++) {
|
for (int i = 0; i < NUM_WIRES; i++) {
|
||||||
out_cut[i] = false;
|
out_cut[i] = false;
|
||||||
@@ -142,17 +144,17 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
|||||||
int white_pos_len = 0;
|
int white_pos_len = 0;
|
||||||
|
|
||||||
for (int i = 0; i < NUM_WIRES; i++) {
|
for (int i = 0; i < NUM_WIRES; i++) {
|
||||||
if (wires[i] == WireColor::red) {
|
if (wires[i] == WireColor::wire_red) {
|
||||||
red_pos[red_pos_len++] = i;
|
red_pos[red_pos_len++] = i;
|
||||||
} else if (wires[i] == WireColor::yellow) {
|
} else if (wires[i] == WireColor::wire_yellow) {
|
||||||
yellow_pos[yellow_pos_len++] = i;
|
yellow_pos[yellow_pos_len++] = i;
|
||||||
} else if (wires[i] == WireColor::green) {
|
} else if (wires[i] == WireColor::wire_green) {
|
||||||
green_pos[green_pos_len++] = i;
|
green_pos[green_pos_len++] = i;
|
||||||
} else if (wires[i] == WireColor::blue) {
|
} else if (wires[i] == WireColor::wire_blue) {
|
||||||
blue_pos[blue_pos_len++] = i;
|
blue_pos[blue_pos_len++] = i;
|
||||||
} else if (wires[i] == WireColor::black) {
|
} else if (wires[i] == WireColor::wire_black) {
|
||||||
black_pos[black_pos_len++] = i;
|
black_pos[black_pos_len++] = i;
|
||||||
} else if (wires[i] == WireColor::white) {
|
} else if (wires[i] == WireColor::wire_white) {
|
||||||
white_pos[white_pos_len++] = i;
|
white_pos[white_pos_len++] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,34 +185,42 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
|||||||
if (list_pos_len[i] == max_len) {
|
if (list_pos_len[i] == max_len) {
|
||||||
int idx = list_pos[i][1];
|
int idx = list_pos[i][1];
|
||||||
out_cut[idx] = true;
|
out_cut[idx] = true;
|
||||||
// ESP_LOGI(TAG, "1. cutting %d", idx);
|
if (debug) {
|
||||||
|
printf("C1. cutting %d\n", idx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. cut the first wire if it is green or white
|
// 2. cut the first wire if it is green or white
|
||||||
if (wires[0] == WireColor::green || wires[0] == WireColor::white) {
|
if (wires[0] == WireColor::wire_green || wires[0] == WireColor::wire_white) {
|
||||||
out_cut[0] = true;
|
out_cut[0] = true;
|
||||||
// ESP_LOGI(TAG, "2. cutting %d", 0);
|
if (debug) {
|
||||||
|
printf("C2. cutting %d\n", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. cut blue wires in even positions (odd indexes)
|
// 3. cut blue wires in even positions (odd indexes)
|
||||||
for (int i = 1; i < NUM_WIRES; i += 2) {
|
for (int i = 1; i < NUM_WIRES; i += 2) {
|
||||||
if (wires[i] == WireColor::blue) {
|
if (wires[i] == WireColor::wire_blue) {
|
||||||
out_cut[i] = true;
|
out_cut[i] = true;
|
||||||
// ESP_LOGI(TAG, "3. cutting %d", i);
|
if (debug) {
|
||||||
|
printf("C3. cutting %d\n", i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. cut black and yellow wires next to black and yellow wires
|
// 4. cut black and yellow wires next to black and yellow wires
|
||||||
for (int i = 0; i < NUM_WIRES-1; i++) {
|
for (int i = 0; i < NUM_WIRES-1; i++) {
|
||||||
if (
|
if (
|
||||||
(wires[i] == WireColor::yellow || wires[i] == WireColor::black) &&
|
(wires[i] == WireColor::wire_yellow || wires[i] == WireColor::wire_black) &&
|
||||||
(wires[i+1] == WireColor::yellow || wires[i+1] == WireColor::black)
|
(wires[i+1] == WireColor::wire_yellow || wires[i+1] == WireColor::wire_black)
|
||||||
) {
|
) {
|
||||||
out_cut[i] = true;
|
out_cut[i] = true;
|
||||||
out_cut[i+1] = true;
|
out_cut[i+1] = true;
|
||||||
// ESP_LOGI(TAG, "4. cutting %d, %d", i, i+1);
|
if (debug) {
|
||||||
|
printf("C4. cutting %d, %d\n", i, i+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,29 +228,35 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
|||||||
for (int green_idx = green_pos_len-1; green_idx >= 0; green_idx--) {
|
for (int green_idx = green_pos_len-1; green_idx >= 0; green_idx--) {
|
||||||
int pos = green_pos[green_idx];
|
int pos = green_pos[green_idx];
|
||||||
if (
|
if (
|
||||||
wires[pos-1] == WireColor::yellow ||
|
wires[pos-1] == WireColor::wire_yellow ||
|
||||||
wires[pos-1] == WireColor::white ||
|
wires[pos-1] == WireColor::wire_white ||
|
||||||
wires[pos+1] == WireColor::yellow ||
|
wires[pos+1] == WireColor::wire_yellow ||
|
||||||
wires[pos+1] == WireColor::white
|
wires[pos+1] == WireColor::wire_white
|
||||||
) {
|
) {
|
||||||
out_cut[pos] = true;
|
out_cut[pos] = true;
|
||||||
// ESP_LOGI(TAG, "5. cutting %d", pos);
|
if (debug) {
|
||||||
|
printf("C5. cutting %d\n", pos);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. cut all white wires if there is a red wire in the 5th position
|
// 6. cut all white wires if there is a red wire in the 5th position
|
||||||
if (wires[4] == WireColor::red) {
|
if (wires[4] == WireColor::wire_red) {
|
||||||
for (int white_idx = 0; white_idx < white_pos_len; white_idx++) {
|
for (int white_idx = 0; white_idx < white_pos_len; white_idx++) {
|
||||||
out_cut[white_pos[white_idx]] = true;
|
out_cut[white_pos[white_idx]] = true;
|
||||||
// ESP_LOGI(TAG, "6. cutting %d", white_pos[white_idx]);
|
if (debug) {
|
||||||
|
printf("C6. cutting %d\n", white_pos[white_idx]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. cut the first black wire if there are more white wires than green wires
|
// 7. cut the first black wire if there are more white wires than green wires
|
||||||
if (white_pos_len > green_pos_len && black_pos_len > 0) {
|
if (white_pos_len > green_pos_len && black_pos_len > 0) {
|
||||||
out_cut[black_pos[0]] = true;
|
out_cut[black_pos[0]] = true;
|
||||||
// ESP_LOGI(TAG, "7. cutting %d", black_pos[0]);
|
if (debug) {
|
||||||
|
printf("C7. cutting %d\n", black_pos[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. cut all wires in an alternating pattern of 2 colors at least 4 wires long
|
// 8. cut all wires in an alternating pattern of 2 colors at least 4 wires long
|
||||||
@@ -254,7 +270,9 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
|||||||
out_cut[i+1] = true;
|
out_cut[i+1] = true;
|
||||||
out_cut[i+2] = true;
|
out_cut[i+2] = true;
|
||||||
out_cut[i+3] = true;
|
out_cut[i+3] = true;
|
||||||
// ESP_LOGI(TAG, "8. cutting %d, %d, %d, %d", i, i+1, i+2, i+3);
|
if (debug) {
|
||||||
|
printf("C8. cutting %d, %d, %d, %d\n", i, i+1, i+2, i+3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +280,9 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
|||||||
for (int i = 0; i < NUM_WIRES; i++) {
|
for (int i = 0; i < NUM_WIRES; i++) {
|
||||||
if (color_name_len[wires[i]] == i+1) {
|
if (color_name_len[wires[i]] == i+1) {
|
||||||
out_cut[i] = true;
|
out_cut[i] = true;
|
||||||
// ESP_LOGI(TAG, "9. cutting %d", i);
|
if (debug) {
|
||||||
|
printf("C9. cutting %d\n", i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,83 +290,119 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
|||||||
if (max_len <= 2) {
|
if (max_len <= 2) {
|
||||||
for (int i = 0; i < red_pos_len; i++) {
|
for (int i = 0; i < red_pos_len; i++) {
|
||||||
out_cut[red_pos[i]] = true;
|
out_cut[red_pos[i]] = true;
|
||||||
// ESP_LOGI(TAG, "10. cutting %d", red_pos[i]);
|
if (debug) {
|
||||||
|
printf("C10. cutting %d\n", red_pos[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 11. cut the last wire if it is the same color as the first wire
|
// 11. cut the last wire if it is the same color as the first wire
|
||||||
if (wires[0] == wires[NUM_WIRES-1]) {
|
if (wires[0] == wires[NUM_WIRES-1]) {
|
||||||
out_cut[NUM_WIRES-1] = true;
|
out_cut[NUM_WIRES-1] = true;
|
||||||
// ESP_LOGI(TAG, "11. cutting %d", NUM_WIRES-1);
|
if (debug) {
|
||||||
|
printf("C11. cutting %d\n", NUM_WIRES-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 12. cut any wire adjacent to both a yellow and blue wire
|
// 12. cut any wire adjacent to both a yellow and blue wire
|
||||||
for (int i = 0; i < NUM_WIRES-2; i++) {
|
for (int i = 0; i < NUM_WIRES-2; i++) {
|
||||||
if (
|
if (
|
||||||
(wires[i] == WireColor::yellow && wires[i+2] == WireColor::blue) ||
|
(wires[i] == WireColor::wire_yellow && wires[i+2] == WireColor::wire_blue) ||
|
||||||
(wires[i] == WireColor::blue && wires[i+2] == WireColor::white)
|
(wires[i] == WireColor::wire_blue && wires[i+2] == WireColor::wire_yellow)
|
||||||
) {
|
) {
|
||||||
out_cut[i+1] = true;
|
out_cut[i+1] = true;
|
||||||
// ESP_LOGI(TAG, "12. cutting %d", i+1);
|
if (debug) {
|
||||||
|
printf("C12. cutting %d\n", i+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NEVER CUT
|
// NEVER CUT
|
||||||
|
|
||||||
// never cut blue wires next to red or green wires
|
// 1. never cut blue wires next to red or green wires
|
||||||
for (int i = 0; i < blue_pos_len; i++) {
|
for (int i = 0; i < blue_pos_len; i++) {
|
||||||
int pos = blue_pos[i];
|
int pos = blue_pos[i];
|
||||||
if (
|
if (
|
||||||
wires[pos-1] == WireColor::red ||
|
wires[pos-1] == WireColor::wire_red ||
|
||||||
wires[pos-1] == WireColor::green ||
|
wires[pos-1] == WireColor::wire_green ||
|
||||||
wires[pos+1] == WireColor::red ||
|
wires[pos+1] == WireColor::wire_red ||
|
||||||
wires[pos+1] == WireColor::green
|
wires[pos+1] == WireColor::wire_green
|
||||||
) {
|
) {
|
||||||
out_cut[pos] = false;
|
out_cut[pos] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N1. Never cutting %d\n", pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// never cut white wires if there is at least one red, black and green wire
|
// 2. never cut white wires if there is at least one red, black and green wire
|
||||||
if (red_pos_len > 0 && green_pos_len > 0 && black_pos_len > 0) {
|
if (red_pos_len > 0 && green_pos_len > 0 && black_pos_len > 0) {
|
||||||
for (int i = 0; i < white_pos_len; i++) {
|
for (int i = 0; i < white_pos_len; i++) {
|
||||||
out_cut[white_pos[i]] = false;
|
out_cut[white_pos[i]] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N2. Never cutting %d\n", white_pos[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// never cut red or black wires in the 4th or 7th positions
|
// 3. never cut red or black wires in the 4th or 7th positions
|
||||||
if (wires[3] == WireColor::red || wires[3] == WireColor::black) {
|
if (wires[3] == WireColor::wire_red || wires[3] == WireColor::wire_black) {
|
||||||
out_cut[3] = false;
|
out_cut[3] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N3. Never cutting %d\n", 3);
|
||||||
}
|
}
|
||||||
if (wires[6] == WireColor::red || wires[6] == WireColor::black) {
|
}
|
||||||
|
if (wires[6] == WireColor::wire_red || wires[6] == WireColor::wire_black) {
|
||||||
out_cut[6] = false;
|
out_cut[6] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N3. Never cutting %d\n", 6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// never cut wires that have the same color on both sides of it
|
// 4. never cut wires that have the same color on both sides of it
|
||||||
for (int i = 0; i < NUM_WIRES-2; i++) {
|
for (int i = 0; i < NUM_WIRES-2; i++) {
|
||||||
if (wires[i] == wires[i+2]) {
|
if (wires[i] == wires[i+2]) {
|
||||||
out_cut[i+1] = false;
|
out_cut[i+1] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N4. Never cutting %d\n", i+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// never cut a wire in the 1st, 2nd, or 3rd position if it is the same color as the wire in the 4th position.
|
// 5. never cut a wire in the 1st, 2nd, or 3rd position if it is the same color as the wire in the 4th position.
|
||||||
if (wires[0] == wires[3]) {
|
if (wires[0] == wires[3]) {
|
||||||
out_cut[0] = false;
|
out_cut[0] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N5. Never cutting %d\n", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (wires[1] == wires[3]) {
|
if (wires[1] == wires[3]) {
|
||||||
out_cut[1] = false;
|
out_cut[1] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N5. Never cutting %d\n", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (wires[2] == wires[3]) {
|
if (wires[2] == wires[3]) {
|
||||||
out_cut[2] = false;
|
out_cut[2] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N5. Never cutting %d\n", 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// never cut a blue or green wire in the 8th postion
|
// 6. never cut a blue or green wire in the 8th postion
|
||||||
if (wires[7] == WireColor::blue || wires[7] == WireColor::green) {
|
if (wires[7] == WireColor::wire_blue || wires[7] == WireColor::wire_green) {
|
||||||
out_cut[7] = false;
|
out_cut[7] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N6. Never cutting %d\n", 7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// never cut a wire in the 5th position if there are no yellow wires
|
// 7. never cut a wire in the 5th position if there are no yellow wires
|
||||||
if (yellow_pos_len == 0) {
|
if (yellow_pos_len == 0) {
|
||||||
out_cut[4] = false;
|
out_cut[4] = false;
|
||||||
|
if (debug) {
|
||||||
|
printf("N7 Never cutting %d\n", 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
#define NUM_WIRES 8
|
#define NUM_WIRES 8
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
red = 0,
|
wire_red = 0,
|
||||||
yellow = 1,
|
wire_yellow = 1,
|
||||||
green = 2,
|
wire_green = 2,
|
||||||
blue = 3,
|
wire_blue = 3,
|
||||||
black = 4,
|
wire_black = 4,
|
||||||
white = 5,
|
wire_white = 5,
|
||||||
} WireColor;
|
} WireColor;
|
||||||
|
|
||||||
void solve_wires(WireColor* wires, bool* out_cut);
|
void solve_wires(WireColor* wires, bool* out_cut);
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
#
|
#
|
||||||
# Automatically generated file. DO NOT EDIT.
|
# Automatically generated file. DO NOT EDIT.
|
||||||
# Espressif IoT Development Framework (ESP-IDF) 5.2.2 Project Configuration
|
# Espressif IoT Development Framework (ESP-IDF) 5.3.2 Project Configuration
|
||||||
#
|
#
|
||||||
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
|
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
|
||||||
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
|
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
|
||||||
CONFIG_SOC_ADC_SUPPORTED=y
|
CONFIG_SOC_ADC_SUPPORTED=y
|
||||||
CONFIG_SOC_UART_SUPPORTED=y
|
CONFIG_SOC_UART_SUPPORTED=y
|
||||||
CONFIG_SOC_PCNT_SUPPORTED=y
|
CONFIG_SOC_PCNT_SUPPORTED=y
|
||||||
|
CONFIG_SOC_PHY_SUPPORTED=y
|
||||||
CONFIG_SOC_WIFI_SUPPORTED=y
|
CONFIG_SOC_WIFI_SUPPORTED=y
|
||||||
CONFIG_SOC_TWAI_SUPPORTED=y
|
CONFIG_SOC_TWAI_SUPPORTED=y
|
||||||
CONFIG_SOC_GDMA_SUPPORTED=y
|
CONFIG_SOC_GDMA_SUPPORTED=y
|
||||||
CONFIG_SOC_AHB_GDMA_SUPPORTED=y
|
CONFIG_SOC_AHB_GDMA_SUPPORTED=y
|
||||||
CONFIG_SOC_GPTIMER_SUPPORTED=y
|
CONFIG_SOC_GPTIMER_SUPPORTED=y
|
||||||
CONFIG_SOC_LCDCAM_SUPPORTED=y
|
CONFIG_SOC_LCDCAM_SUPPORTED=y
|
||||||
|
CONFIG_SOC_LCDCAM_I80_LCD_SUPPORTED=y
|
||||||
|
CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED=y
|
||||||
CONFIG_SOC_MCPWM_SUPPORTED=y
|
CONFIG_SOC_MCPWM_SUPPORTED=y
|
||||||
CONFIG_SOC_DEDICATED_GPIO_SUPPORTED=y
|
CONFIG_SOC_DEDICATED_GPIO_SUPPORTED=y
|
||||||
CONFIG_SOC_CACHE_SUPPORT_WRAP=y
|
CONFIG_SOC_CACHE_SUPPORT_WRAP=y
|
||||||
@@ -56,6 +59,11 @@ CONFIG_SOC_CLK_TREE_SUPPORTED=y
|
|||||||
CONFIG_SOC_MPU_SUPPORTED=y
|
CONFIG_SOC_MPU_SUPPORTED=y
|
||||||
CONFIG_SOC_WDT_SUPPORTED=y
|
CONFIG_SOC_WDT_SUPPORTED=y
|
||||||
CONFIG_SOC_SPI_FLASH_SUPPORTED=y
|
CONFIG_SOC_SPI_FLASH_SUPPORTED=y
|
||||||
|
CONFIG_SOC_RNG_SUPPORTED=y
|
||||||
|
CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y
|
||||||
|
CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y
|
||||||
|
CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y
|
||||||
|
CONFIG_SOC_PM_SUPPORTED=y
|
||||||
CONFIG_SOC_XTAL_SUPPORT_40M=y
|
CONFIG_SOC_XTAL_SUPPORT_40M=y
|
||||||
CONFIG_SOC_APPCPU_HAS_CLOCK_GATING_BUG=y
|
CONFIG_SOC_APPCPU_HAS_CLOCK_GATING_BUG=y
|
||||||
CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y
|
CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y
|
||||||
@@ -112,10 +120,13 @@ CONFIG_SOC_GPIO_IN_RANGE_MAX=48
|
|||||||
CONFIG_SOC_GPIO_OUT_RANGE_MAX=48
|
CONFIG_SOC_GPIO_OUT_RANGE_MAX=48
|
||||||
CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x0001FFFFFC000000
|
CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x0001FFFFFC000000
|
||||||
CONFIG_SOC_GPIO_CLOCKOUT_BY_IO_MUX=y
|
CONFIG_SOC_GPIO_CLOCKOUT_BY_IO_MUX=y
|
||||||
|
CONFIG_SOC_GPIO_CLOCKOUT_CHANNEL_NUM=3
|
||||||
|
CONFIG_SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP=y
|
||||||
CONFIG_SOC_DEDIC_GPIO_OUT_CHANNELS_NUM=8
|
CONFIG_SOC_DEDIC_GPIO_OUT_CHANNELS_NUM=8
|
||||||
CONFIG_SOC_DEDIC_GPIO_IN_CHANNELS_NUM=8
|
CONFIG_SOC_DEDIC_GPIO_IN_CHANNELS_NUM=8
|
||||||
CONFIG_SOC_DEDIC_GPIO_OUT_AUTO_ENABLE=y
|
CONFIG_SOC_DEDIC_GPIO_OUT_AUTO_ENABLE=y
|
||||||
CONFIG_SOC_I2C_NUM=2
|
CONFIG_SOC_I2C_NUM=2
|
||||||
|
CONFIG_SOC_HP_I2C_NUM=2
|
||||||
CONFIG_SOC_I2C_FIFO_LEN=32
|
CONFIG_SOC_I2C_FIFO_LEN=32
|
||||||
CONFIG_SOC_I2C_CMD_REG_NUM=8
|
CONFIG_SOC_I2C_CMD_REG_NUM=8
|
||||||
CONFIG_SOC_I2C_SUPPORT_SLAVE=y
|
CONFIG_SOC_I2C_SUPPORT_SLAVE=y
|
||||||
@@ -181,6 +192,10 @@ CONFIG_SOC_LCD_RGB_PANELS=1
|
|||||||
CONFIG_SOC_LCD_I80_BUS_WIDTH=16
|
CONFIG_SOC_LCD_I80_BUS_WIDTH=16
|
||||||
CONFIG_SOC_LCD_RGB_DATA_WIDTH=16
|
CONFIG_SOC_LCD_RGB_DATA_WIDTH=16
|
||||||
CONFIG_SOC_LCD_SUPPORT_RGB_YUV_CONV=y
|
CONFIG_SOC_LCD_SUPPORT_RGB_YUV_CONV=y
|
||||||
|
CONFIG_SOC_LCDCAM_I80_NUM_BUSES=1
|
||||||
|
CONFIG_SOC_LCDCAM_I80_BUS_WIDTH=16
|
||||||
|
CONFIG_SOC_LCDCAM_RGB_NUM_PANELS=1
|
||||||
|
CONFIG_SOC_LCDCAM_RGB_DATA_WIDTH=16
|
||||||
CONFIG_SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH=128
|
CONFIG_SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH=128
|
||||||
CONFIG_SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM=549
|
CONFIG_SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM=549
|
||||||
CONFIG_SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH=128
|
CONFIG_SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH=128
|
||||||
@@ -205,6 +220,10 @@ CONFIG_SOC_SPI_PERIPH_SUPPORT_CONTROL_DUMMY_OUT=y
|
|||||||
CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y
|
CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y
|
||||||
CONFIG_SOC_SPI_MAX_PRE_DIVIDER=16
|
CONFIG_SOC_SPI_MAX_PRE_DIVIDER=16
|
||||||
CONFIG_SOC_SPI_SUPPORT_OCT=y
|
CONFIG_SOC_SPI_SUPPORT_OCT=y
|
||||||
|
CONFIG_SOC_SPI_SCT_SUPPORTED=y
|
||||||
|
CONFIG_SOC_SPI_SCT_REG_NUM=14
|
||||||
|
CONFIG_SOC_SPI_SCT_BUFFER_NUM_MAX=y
|
||||||
|
CONFIG_SOC_SPI_SCT_CONF_BITLEN_MAX=0x3FFFA
|
||||||
CONFIG_SOC_MEMSPI_SRC_FREQ_120M=y
|
CONFIG_SOC_MEMSPI_SRC_FREQ_120M=y
|
||||||
CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y
|
CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y
|
||||||
CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y
|
CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y
|
||||||
@@ -224,12 +243,14 @@ CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=54
|
|||||||
CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y
|
CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y
|
||||||
CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y
|
CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y
|
||||||
CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=4
|
CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=4
|
||||||
CONFIG_SOC_TOUCH_VERSION_2=y
|
CONFIG_SOC_TOUCH_SENSOR_VERSION=2
|
||||||
CONFIG_SOC_TOUCH_SENSOR_NUM=15
|
CONFIG_SOC_TOUCH_SENSOR_NUM=15
|
||||||
|
CONFIG_SOC_TOUCH_SUPPORT_SLEEP_WAKEUP=y
|
||||||
|
CONFIG_SOC_TOUCH_SUPPORT_WATERPROOF=y
|
||||||
|
CONFIG_SOC_TOUCH_SUPPORT_PROX_SENSING=y
|
||||||
CONFIG_SOC_TOUCH_PROXIMITY_CHANNEL_NUM=3
|
CONFIG_SOC_TOUCH_PROXIMITY_CHANNEL_NUM=3
|
||||||
CONFIG_SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED=y
|
CONFIG_SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED=y
|
||||||
CONFIG_SOC_TOUCH_PAD_THRESHOLD_MAX=0x1FFFFF
|
CONFIG_SOC_TOUCH_SAMPLE_CFG_NUM=1
|
||||||
CONFIG_SOC_TOUCH_PAD_MEASURE_WAIT_MAX=0xFF
|
|
||||||
CONFIG_SOC_TWAI_CONTROLLER_NUM=1
|
CONFIG_SOC_TWAI_CONTROLLER_NUM=1
|
||||||
CONFIG_SOC_TWAI_CLK_SUPPORT_APB=y
|
CONFIG_SOC_TWAI_CLK_SUPPORT_APB=y
|
||||||
CONFIG_SOC_TWAI_BRP_MIN=2
|
CONFIG_SOC_TWAI_BRP_MIN=2
|
||||||
@@ -317,6 +338,7 @@ CONFIG_SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE=y
|
|||||||
CONFIG_SOC_SPI_MEM_SUPPORT_WRAP=y
|
CONFIG_SOC_SPI_MEM_SUPPORT_WRAP=y
|
||||||
CONFIG_SOC_MEMSPI_TIMING_TUNING_BY_MSPI_DELAY=y
|
CONFIG_SOC_MEMSPI_TIMING_TUNING_BY_MSPI_DELAY=y
|
||||||
CONFIG_SOC_MEMSPI_CORE_CLK_SHARED_WITH_PSRAM=y
|
CONFIG_SOC_MEMSPI_CORE_CLK_SHARED_WITH_PSRAM=y
|
||||||
|
CONFIG_SOC_SPI_MEM_SUPPORT_CACHE_32BIT_ADDR_MAP=y
|
||||||
CONFIG_SOC_COEX_HW_PTI=y
|
CONFIG_SOC_COEX_HW_PTI=y
|
||||||
CONFIG_SOC_EXTERNAL_COEX_LEADER_TX_LINE=y
|
CONFIG_SOC_EXTERNAL_COEX_LEADER_TX_LINE=y
|
||||||
CONFIG_SOC_SDMMC_USE_GPIO_MATRIX=y
|
CONFIG_SOC_SDMMC_USE_GPIO_MATRIX=y
|
||||||
@@ -344,7 +366,7 @@ CONFIG_IDF_TOOLCHAIN="gcc"
|
|||||||
CONFIG_IDF_TARGET_ARCH_XTENSA=y
|
CONFIG_IDF_TARGET_ARCH_XTENSA=y
|
||||||
CONFIG_IDF_TARGET_ARCH="xtensa"
|
CONFIG_IDF_TARGET_ARCH="xtensa"
|
||||||
CONFIG_IDF_TARGET="esp32s3"
|
CONFIG_IDF_TARGET="esp32s3"
|
||||||
CONFIG_IDF_INIT_VERSION="5.2.1"
|
CONFIG_IDF_INIT_VERSION="5.2.2"
|
||||||
CONFIG_IDF_TARGET_ESP32S3=y
|
CONFIG_IDF_TARGET_ESP32S3=y
|
||||||
CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009
|
CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009
|
||||||
|
|
||||||
@@ -443,13 +465,17 @@ CONFIG_ESP_ROM_NEEDS_SWSETUP_WORKAROUND=y
|
|||||||
CONFIG_ESP_ROM_HAS_LAYOUT_TABLE=y
|
CONFIG_ESP_ROM_HAS_LAYOUT_TABLE=y
|
||||||
CONFIG_ESP_ROM_HAS_SPI_FLASH=y
|
CONFIG_ESP_ROM_HAS_SPI_FLASH=y
|
||||||
CONFIG_ESP_ROM_HAS_ETS_PRINTF_BUG=y
|
CONFIG_ESP_ROM_HAS_ETS_PRINTF_BUG=y
|
||||||
|
CONFIG_ESP_ROM_HAS_NEWLIB=y
|
||||||
CONFIG_ESP_ROM_HAS_NEWLIB_NANO_FORMAT=y
|
CONFIG_ESP_ROM_HAS_NEWLIB_NANO_FORMAT=y
|
||||||
|
CONFIG_ESP_ROM_HAS_NEWLIB_32BIT_TIME=y
|
||||||
CONFIG_ESP_ROM_NEEDS_SET_CACHE_MMU_SIZE=y
|
CONFIG_ESP_ROM_NEEDS_SET_CACHE_MMU_SIZE=y
|
||||||
CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT=y
|
CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT=y
|
||||||
CONFIG_ESP_ROM_HAS_FLASH_COUNT_PAGES_BUG=y
|
CONFIG_ESP_ROM_HAS_FLASH_COUNT_PAGES_BUG=y
|
||||||
CONFIG_ESP_ROM_HAS_CACHE_SUSPEND_WAITI_BUG=y
|
CONFIG_ESP_ROM_HAS_CACHE_SUSPEND_WAITI_BUG=y
|
||||||
CONFIG_ESP_ROM_HAS_CACHE_WRITEBACK_BUG=y
|
CONFIG_ESP_ROM_HAS_CACHE_WRITEBACK_BUG=y
|
||||||
CONFIG_ESP_ROM_HAS_SW_FLOAT=y
|
CONFIG_ESP_ROM_HAS_SW_FLOAT=y
|
||||||
|
CONFIG_ESP_ROM_HAS_VERSION=y
|
||||||
|
CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# Boot ROM Behavior
|
# Boot ROM Behavior
|
||||||
@@ -510,6 +536,12 @@ CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
|||||||
CONFIG_PARTITION_TABLE_MD5=y
|
CONFIG_PARTITION_TABLE_MD5=y
|
||||||
# end of Partition Table
|
# end of Partition Table
|
||||||
|
|
||||||
|
#
|
||||||
|
# BLK_BOX Config
|
||||||
|
#
|
||||||
|
CONFIG_USE_NEW_DISPLAY=y
|
||||||
|
# end of BLK_BOX Config
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compiler options
|
# Compiler options
|
||||||
#
|
#
|
||||||
@@ -536,6 +568,8 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y
|
|||||||
# CONFIG_COMPILER_DUMP_RTL_FILES is not set
|
# CONFIG_COMPILER_DUMP_RTL_FILES is not set
|
||||||
CONFIG_COMPILER_RT_LIB_GCCLIB=y
|
CONFIG_COMPILER_RT_LIB_GCCLIB=y
|
||||||
CONFIG_COMPILER_RT_LIB_NAME="gcc"
|
CONFIG_COMPILER_RT_LIB_NAME="gcc"
|
||||||
|
# CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING is not set
|
||||||
|
CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y
|
||||||
# end of Compiler options
|
# end of Compiler options
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -562,31 +596,16 @@ CONFIG_APPTRACE_LOCK_ENABLE=y
|
|||||||
CONFIG_BT_ALARM_MAX_NUM=50
|
CONFIG_BT_ALARM_MAX_NUM=50
|
||||||
# end of Bluetooth
|
# end of Bluetooth
|
||||||
|
|
||||||
|
#
|
||||||
|
# Console Library
|
||||||
|
#
|
||||||
|
# CONFIG_CONSOLE_SORTED_HELP is not set
|
||||||
|
# end of Console Library
|
||||||
|
|
||||||
#
|
#
|
||||||
# Driver Configurations
|
# Driver Configurations
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
|
||||||
# Legacy ADC Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set
|
|
||||||
|
|
||||||
#
|
|
||||||
# Legacy ADC Calibration Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_ADC_CALI_SUPPRESS_DEPRECATE_WARN is not set
|
|
||||||
# end of Legacy ADC Calibration Configuration
|
|
||||||
# end of Legacy ADC Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# SPI Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_SPI_MASTER_IN_IRAM is not set
|
|
||||||
CONFIG_SPI_MASTER_ISR_IN_IRAM=y
|
|
||||||
# CONFIG_SPI_SLAVE_IN_IRAM is not set
|
|
||||||
CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
|
|
||||||
# end of SPI Configuration
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# TWAI Configuration
|
# TWAI Configuration
|
||||||
#
|
#
|
||||||
@@ -595,94 +614,58 @@ CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y
|
|||||||
# end of TWAI Configuration
|
# end of TWAI Configuration
|
||||||
|
|
||||||
#
|
#
|
||||||
# Temperature sensor Configuration
|
# Legacy ADC Driver Configuration
|
||||||
|
#
|
||||||
|
# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy ADC Calibration Configuration
|
||||||
|
#
|
||||||
|
# CONFIG_ADC_CALI_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
|
# end of Legacy ADC Calibration Configuration
|
||||||
|
# end of Legacy ADC Driver Configuration
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy MCPWM Driver Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
|
# end of Legacy MCPWM Driver Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy Timer Group Driver Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
|
# end of Legacy Timer Group Driver Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy RMT Driver Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
|
# end of Legacy RMT Driver Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy I2S Driver Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
|
# end of Legacy I2S Driver Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy PCNT Driver Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
|
# end of Legacy PCNT Driver Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy SDM Driver Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
|
# end of Legacy SDM Driver Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy Temperature Sensor Driver Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN is not set
|
# CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
# CONFIG_TEMP_SENSOR_ENABLE_DEBUG_LOG is not set
|
# end of Legacy Temperature Sensor Driver Configurations
|
||||||
# end of Temperature sensor Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# UART Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_UART_ISR_IN_IRAM is not set
|
|
||||||
# end of UART Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# GPIO Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_GPIO_CTRL_FUNC_IN_IRAM is not set
|
|
||||||
# end of GPIO Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# Sigma Delta Modulator Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_SDM_CTRL_FUNC_IN_IRAM is not set
|
|
||||||
# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set
|
|
||||||
# CONFIG_SDM_ENABLE_DEBUG_LOG is not set
|
|
||||||
# end of Sigma Delta Modulator Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# GPTimer Configuration
|
|
||||||
#
|
|
||||||
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y
|
|
||||||
# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set
|
|
||||||
# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set
|
|
||||||
# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set
|
|
||||||
# CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set
|
|
||||||
# end of GPTimer Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# PCNT Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_PCNT_CTRL_FUNC_IN_IRAM is not set
|
|
||||||
# CONFIG_PCNT_ISR_IRAM_SAFE is not set
|
|
||||||
# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set
|
|
||||||
# CONFIG_PCNT_ENABLE_DEBUG_LOG is not set
|
|
||||||
# end of PCNT Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# RMT Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_RMT_ISR_IRAM_SAFE is not set
|
|
||||||
# CONFIG_RMT_RECV_FUNC_IN_IRAM is not set
|
|
||||||
# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set
|
|
||||||
# CONFIG_RMT_ENABLE_DEBUG_LOG is not set
|
|
||||||
# end of RMT Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# MCPWM Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_MCPWM_ISR_IRAM_SAFE is not set
|
|
||||||
# CONFIG_MCPWM_CTRL_FUNC_IN_IRAM is not set
|
|
||||||
# CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set
|
|
||||||
# CONFIG_MCPWM_ENABLE_DEBUG_LOG is not set
|
|
||||||
# end of MCPWM Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# I2S Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_I2S_ISR_IRAM_SAFE is not set
|
|
||||||
# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set
|
|
||||||
# CONFIG_I2S_ENABLE_DEBUG_LOG is not set
|
|
||||||
# end of I2S Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# USB Serial/JTAG Configuration
|
|
||||||
#
|
|
||||||
# end of USB Serial/JTAG Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# LEDC Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_LEDC_CTRL_FUNC_IN_IRAM is not set
|
|
||||||
# end of LEDC Configuration
|
|
||||||
|
|
||||||
#
|
|
||||||
# I2C Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_I2C_ISR_IRAM_SAFE is not set
|
|
||||||
# CONFIG_I2C_ENABLE_DEBUG_LOG is not set
|
|
||||||
# end of I2C Configuration
|
|
||||||
# end of Driver Configurations
|
# end of Driver Configurations
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -699,7 +682,9 @@ CONFIG_EFUSE_MAX_BLK_LEN=256
|
|||||||
CONFIG_ESP_TLS_USING_MBEDTLS=y
|
CONFIG_ESP_TLS_USING_MBEDTLS=y
|
||||||
CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y
|
CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y
|
||||||
# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set
|
# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set
|
||||||
# CONFIG_ESP_TLS_SERVER is not set
|
# CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set
|
||||||
|
# CONFIG_ESP_TLS_SERVER_CERT_SELECT_HOOK is not set
|
||||||
|
# CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set
|
||||||
# CONFIG_ESP_TLS_PSK_VERIFICATION is not set
|
# CONFIG_ESP_TLS_PSK_VERIFICATION is not set
|
||||||
# CONFIG_ESP_TLS_INSECURE is not set
|
# CONFIG_ESP_TLS_INSECURE is not set
|
||||||
# end of ESP-TLS
|
# end of ESP-TLS
|
||||||
@@ -710,12 +695,15 @@ CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y
|
|||||||
# CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM is not set
|
# CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM is not set
|
||||||
# CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE is not set
|
# CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE is not set
|
||||||
# CONFIG_ADC_CONTINUOUS_FORCE_USE_ADC2_ON_C3_S3 is not set
|
# CONFIG_ADC_CONTINUOUS_FORCE_USE_ADC2_ON_C3_S3 is not set
|
||||||
|
# CONFIG_ADC_ENABLE_DEBUG_LOG is not set
|
||||||
# end of ADC and ADC Calibration
|
# end of ADC and ADC Calibration
|
||||||
|
|
||||||
#
|
#
|
||||||
# Wireless Coexistence
|
# Wireless Coexistence
|
||||||
#
|
#
|
||||||
|
CONFIG_ESP_COEX_ENABLED=y
|
||||||
# CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE is not set
|
# CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE is not set
|
||||||
|
# CONFIG_ESP_COEX_GPIO_DEBUG is not set
|
||||||
# end of Wireless Coexistence
|
# end of Wireless Coexistence
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -724,6 +712,107 @@ CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y
|
|||||||
CONFIG_ESP_ERR_TO_NAME_LOOKUP=y
|
CONFIG_ESP_ERR_TO_NAME_LOOKUP=y
|
||||||
# end of Common ESP-related
|
# end of Common ESP-related
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:GPIO Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_GPIO_CTRL_FUNC_IN_IRAM is not set
|
||||||
|
# end of ESP-Driver:GPIO Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:GPTimer Configurations
|
||||||
|
#
|
||||||
|
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y
|
||||||
|
# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set
|
||||||
|
# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set
|
||||||
|
# CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:GPTimer Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:I2C Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_I2C_ISR_IRAM_SAFE is not set
|
||||||
|
# CONFIG_I2C_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:I2C Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:I2S Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_I2S_ISR_IRAM_SAFE is not set
|
||||||
|
# CONFIG_I2S_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:I2S Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:LEDC Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_LEDC_CTRL_FUNC_IN_IRAM is not set
|
||||||
|
# end of ESP-Driver:LEDC Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:MCPWM Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_MCPWM_ISR_IRAM_SAFE is not set
|
||||||
|
# CONFIG_MCPWM_CTRL_FUNC_IN_IRAM is not set
|
||||||
|
# CONFIG_MCPWM_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:MCPWM Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:PCNT Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_PCNT_CTRL_FUNC_IN_IRAM is not set
|
||||||
|
# CONFIG_PCNT_ISR_IRAM_SAFE is not set
|
||||||
|
# CONFIG_PCNT_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:PCNT Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:RMT Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_RMT_ISR_IRAM_SAFE is not set
|
||||||
|
# CONFIG_RMT_RECV_FUNC_IN_IRAM is not set
|
||||||
|
# CONFIG_RMT_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:RMT Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:Sigma Delta Modulator Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_SDM_CTRL_FUNC_IN_IRAM is not set
|
||||||
|
# CONFIG_SDM_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:Sigma Delta Modulator Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:SPI Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_SPI_MASTER_IN_IRAM is not set
|
||||||
|
CONFIG_SPI_MASTER_ISR_IN_IRAM=y
|
||||||
|
# CONFIG_SPI_SLAVE_IN_IRAM is not set
|
||||||
|
CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
|
||||||
|
# end of ESP-Driver:SPI Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:Touch Sensor Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_TOUCH_CTRL_FUNC_IN_IRAM is not set
|
||||||
|
# CONFIG_TOUCH_ISR_IRAM_SAFE is not set
|
||||||
|
# CONFIG_TOUCH_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:Touch Sensor Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:Temperature Sensor Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_TEMP_SENSOR_ENABLE_DEBUG_LOG is not set
|
||||||
|
# end of ESP-Driver:Temperature Sensor Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:UART Configurations
|
||||||
|
#
|
||||||
|
# CONFIG_UART_ISR_IN_IRAM is not set
|
||||||
|
# end of ESP-Driver:UART Configurations
|
||||||
|
|
||||||
|
#
|
||||||
|
# ESP-Driver:USB Serial/JTAG Configuration
|
||||||
|
#
|
||||||
|
CONFIG_USJ_ENABLE_USB_SERIAL_JTAG=y
|
||||||
|
# end of ESP-Driver:USB Serial/JTAG Configuration
|
||||||
|
|
||||||
#
|
#
|
||||||
# Ethernet
|
# Ethernet
|
||||||
#
|
#
|
||||||
@@ -759,6 +848,7 @@ CONFIG_ESP_GDBSTUB_MAX_TASKS=32
|
|||||||
CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y
|
CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y
|
||||||
# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set
|
# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set
|
||||||
# CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set
|
# CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set
|
||||||
|
# CONFIG_ESP_HTTP_CLIENT_ENABLE_CUSTOM_TRANSPORT is not set
|
||||||
# end of ESP HTTP client
|
# end of ESP HTTP client
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -804,6 +894,12 @@ CONFIG_ESP_REV_MIN_FULL=0
|
|||||||
#
|
#
|
||||||
CONFIG_ESP32S3_REV_MAX_FULL=99
|
CONFIG_ESP32S3_REV_MAX_FULL=99
|
||||||
CONFIG_ESP_REV_MAX_FULL=99
|
CONFIG_ESP_REV_MAX_FULL=99
|
||||||
|
CONFIG_ESP_EFUSE_BLOCK_REV_MIN_FULL=0
|
||||||
|
CONFIG_ESP_EFUSE_BLOCK_REV_MAX_FULL=199
|
||||||
|
|
||||||
|
#
|
||||||
|
# Maximum Supported ESP32-S3 eFuse Block Revision (eFuse Block Rev v1.99)
|
||||||
|
#
|
||||||
# end of Chip revision
|
# end of Chip revision
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -814,6 +910,7 @@ CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y
|
|||||||
CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y
|
CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y
|
||||||
CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y
|
CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y
|
||||||
CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y
|
CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y
|
||||||
|
CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES=4
|
||||||
# CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO is not set
|
# CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO is not set
|
||||||
CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR=y
|
CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR=y
|
||||||
CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4
|
CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4
|
||||||
@@ -851,12 +948,12 @@ CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y
|
|||||||
# end of Peripheral Control
|
# end of Peripheral Control
|
||||||
|
|
||||||
#
|
#
|
||||||
# GDMA Configuration
|
# GDMA Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set
|
CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y
|
||||||
# CONFIG_GDMA_ISR_IRAM_SAFE is not set
|
# CONFIG_GDMA_ISR_IRAM_SAFE is not set
|
||||||
# CONFIG_GDMA_ENABLE_DEBUG_LOG is not set
|
# CONFIG_GDMA_ENABLE_DEBUG_LOG is not set
|
||||||
# end of GDMA Configuration
|
# end of GDMA Configurations
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main XTAL Config
|
# Main XTAL Config
|
||||||
@@ -864,6 +961,8 @@ CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y
|
|||||||
CONFIG_XTAL_FREQ_40=y
|
CONFIG_XTAL_FREQ_40=y
|
||||||
CONFIG_XTAL_FREQ=40
|
CONFIG_XTAL_FREQ=40
|
||||||
# end of Main XTAL Config
|
# end of Main XTAL Config
|
||||||
|
|
||||||
|
CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y
|
||||||
# end of Hardware Settings
|
# end of Hardware Settings
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -877,7 +976,6 @@ CONFIG_XTAL_FREQ=40
|
|||||||
#
|
#
|
||||||
# LCD Peripheral Configuration
|
# LCD Peripheral Configuration
|
||||||
#
|
#
|
||||||
CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32
|
|
||||||
# CONFIG_LCD_ENABLE_DEBUG_LOG is not set
|
# CONFIG_LCD_ENABLE_DEBUG_LOG is not set
|
||||||
# CONFIG_LCD_RGB_ISR_IRAM_SAFE is not set
|
# CONFIG_LCD_RGB_ISR_IRAM_SAFE is not set
|
||||||
# CONFIG_LCD_RGB_RESTART_IN_VSYNC is not set
|
# CONFIG_LCD_RGB_RESTART_IN_VSYNC is not set
|
||||||
@@ -894,6 +992,7 @@ CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y
|
|||||||
# CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set
|
# CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set
|
||||||
# CONFIG_ESP_NETIF_L2_TAP is not set
|
# CONFIG_ESP_NETIF_L2_TAP is not set
|
||||||
# CONFIG_ESP_NETIF_BRIDGE_EN is not set
|
# CONFIG_ESP_NETIF_BRIDGE_EN is not set
|
||||||
|
# CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF is not set
|
||||||
# end of ESP NETIF Adapter
|
# end of ESP NETIF Adapter
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -904,6 +1003,7 @@ CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y
|
|||||||
#
|
#
|
||||||
# PHY
|
# PHY
|
||||||
#
|
#
|
||||||
|
CONFIG_ESP_PHY_ENABLED=y
|
||||||
CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y
|
CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y
|
||||||
# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set
|
# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set
|
||||||
CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20
|
CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20
|
||||||
@@ -922,6 +1022,7 @@ CONFIG_ESP_PHY_CALIBRATION_MODE=0
|
|||||||
# Power Management
|
# Power Management
|
||||||
#
|
#
|
||||||
# CONFIG_PM_ENABLE is not set
|
# CONFIG_PM_ENABLE is not set
|
||||||
|
# CONFIG_PM_SLP_IRAM_OPT is not set
|
||||||
CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y
|
CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y
|
||||||
CONFIG_PM_RESTORE_CACHE_TAGMEM_AFTER_LIGHT_SLEEP=y
|
CONFIG_PM_RESTORE_CACHE_TAGMEM_AFTER_LIGHT_SLEEP=y
|
||||||
# end of Power Management
|
# end of Power Management
|
||||||
@@ -1018,6 +1119,7 @@ CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y
|
|||||||
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y
|
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y
|
||||||
CONFIG_ESP_CONSOLE_UART=y
|
CONFIG_ESP_CONSOLE_UART=y
|
||||||
CONFIG_ESP_CONSOLE_UART_NUM=0
|
CONFIG_ESP_CONSOLE_UART_NUM=0
|
||||||
|
CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0
|
||||||
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
|
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
|
||||||
CONFIG_ESP_INT_WDT=y
|
CONFIG_ESP_INT_WDT=y
|
||||||
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
|
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
|
||||||
@@ -1060,7 +1162,7 @@ CONFIG_ESP_IPC_ISR_ENABLE=y
|
|||||||
# end of IPC (Inter-Processor Call)
|
# end of IPC (Inter-Processor Call)
|
||||||
|
|
||||||
#
|
#
|
||||||
# High resolution timer (esp_timer)
|
# ESP Timer (High Resolution Timer)
|
||||||
#
|
#
|
||||||
# CONFIG_ESP_TIMER_PROFILING is not set
|
# CONFIG_ESP_TIMER_PROFILING is not set
|
||||||
CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y
|
CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y
|
||||||
@@ -1070,11 +1172,10 @@ CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1
|
|||||||
# CONFIG_ESP_TIMER_SHOW_EXPERIMENTAL is not set
|
# CONFIG_ESP_TIMER_SHOW_EXPERIMENTAL is not set
|
||||||
CONFIG_ESP_TIMER_TASK_AFFINITY=0x0
|
CONFIG_ESP_TIMER_TASK_AFFINITY=0x0
|
||||||
CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0=y
|
CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0=y
|
||||||
CONFIG_ESP_TIMER_ISR_AFFINITY=0x1
|
|
||||||
CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0=y
|
CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0=y
|
||||||
# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set
|
# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set
|
||||||
CONFIG_ESP_TIMER_IMPL_SYSTIMER=y
|
CONFIG_ESP_TIMER_IMPL_SYSTIMER=y
|
||||||
# end of High resolution timer (esp_timer)
|
# end of ESP Timer (High Resolution Timer)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Wi-Fi
|
# Wi-Fi
|
||||||
@@ -1108,6 +1209,9 @@ CONFIG_ESP_WIFI_ENABLE_SAE_PK=y
|
|||||||
CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y
|
CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y
|
||||||
CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y
|
CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y
|
||||||
# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set
|
# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set
|
||||||
|
CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50
|
||||||
|
CONFIG_ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME=10
|
||||||
|
CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15
|
||||||
# CONFIG_ESP_WIFI_FTM_ENABLE is not set
|
# CONFIG_ESP_WIFI_FTM_ENABLE is not set
|
||||||
CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE=y
|
CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE=y
|
||||||
# CONFIG_ESP_WIFI_GCMP_SUPPORT is not set
|
# CONFIG_ESP_WIFI_GCMP_SUPPORT is not set
|
||||||
@@ -1184,6 +1288,8 @@ CONFIG_FATFS_PER_FILE_CACHE=y
|
|||||||
# CONFIG_FATFS_USE_FASTSEEK is not set
|
# CONFIG_FATFS_USE_FASTSEEK is not set
|
||||||
CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0
|
CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0
|
||||||
# CONFIG_FATFS_IMMEDIATE_FSYNC is not set
|
# CONFIG_FATFS_IMMEDIATE_FSYNC is not set
|
||||||
|
# CONFIG_FATFS_USE_LABEL is not set
|
||||||
|
CONFIG_FATFS_LINK_LOCK=y
|
||||||
# end of FAT Filesystem support
|
# end of FAT Filesystem support
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1206,12 +1312,17 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536
|
|||||||
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
|
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
|
||||||
# CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY is not set
|
# CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY is not set
|
||||||
CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME="Tmr Svc"
|
CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME="Tmr Svc"
|
||||||
|
# CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU0 is not set
|
||||||
|
# CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU1 is not set
|
||||||
|
CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY=y
|
||||||
|
CONFIG_FREERTOS_TIMER_SERVICE_TASK_CORE_AFFINITY=0x7FFFFFFF
|
||||||
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
|
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
|
||||||
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
|
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
|
||||||
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
|
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
|
||||||
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
|
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
|
||||||
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1
|
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1
|
||||||
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
|
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
|
||||||
|
# CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES is not set
|
||||||
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
||||||
# CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG is not set
|
# CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG is not set
|
||||||
# end of Kernel
|
# end of Kernel
|
||||||
@@ -1241,6 +1352,7 @@ CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
|
|||||||
CONFIG_FREERTOS_DEBUG_OCDAWARE=y
|
CONFIG_FREERTOS_DEBUG_OCDAWARE=y
|
||||||
CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y
|
CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y
|
||||||
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
|
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
|
||||||
|
CONFIG_FREERTOS_NUMBER_OF_CORES=2
|
||||||
# end of FreeRTOS
|
# end of FreeRTOS
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1254,6 +1366,7 @@ CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2
|
|||||||
CONFIG_HAL_WDT_USE_ROM_IMPL=y
|
CONFIG_HAL_WDT_USE_ROM_IMPL=y
|
||||||
CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y
|
CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y
|
||||||
CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y
|
CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y
|
||||||
|
# CONFIG_HAL_ECDSA_GEN_SIG_CM is not set
|
||||||
# end of Hardware Abstraction Layer (HAL) and Low Level (LL)
|
# end of Hardware Abstraction Layer (HAL) and Low Level (LL)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1369,6 +1482,7 @@ CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT=20000
|
|||||||
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5760
|
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5760
|
||||||
CONFIG_LWIP_TCP_WND_DEFAULT=5760
|
CONFIG_LWIP_TCP_WND_DEFAULT=5760
|
||||||
CONFIG_LWIP_TCP_RECVMBOX_SIZE=6
|
CONFIG_LWIP_TCP_RECVMBOX_SIZE=6
|
||||||
|
CONFIG_LWIP_TCP_ACCEPTMBOX_SIZE=6
|
||||||
CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
|
CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
|
||||||
CONFIG_LWIP_TCP_OOSEQ_TIMEOUT=6
|
CONFIG_LWIP_TCP_OOSEQ_TIMEOUT=6
|
||||||
CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4
|
CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4
|
||||||
@@ -1399,6 +1513,9 @@ CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
|
|||||||
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set
|
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set
|
||||||
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set
|
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set
|
||||||
CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF
|
CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF
|
||||||
|
CONFIG_LWIP_IPV6_ND6_NUM_PREFIXES=5
|
||||||
|
CONFIG_LWIP_IPV6_ND6_NUM_ROUTERS=3
|
||||||
|
CONFIG_LWIP_IPV6_ND6_NUM_DESTINATIONS=10
|
||||||
# CONFIG_LWIP_PPP_SUPPORT is not set
|
# CONFIG_LWIP_PPP_SUPPORT is not set
|
||||||
CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3
|
CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3
|
||||||
CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5
|
CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5
|
||||||
@@ -1424,13 +1541,17 @@ CONFIG_LWIP_MAX_RAW_PCBS=16
|
|||||||
CONFIG_LWIP_SNTP_MAX_SERVERS=1
|
CONFIG_LWIP_SNTP_MAX_SERVERS=1
|
||||||
# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set
|
# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set
|
||||||
CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000
|
CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000
|
||||||
|
CONFIG_LWIP_SNTP_STARTUP_DELAY=y
|
||||||
|
CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY=5000
|
||||||
# end of SNTP
|
# end of SNTP
|
||||||
|
|
||||||
#
|
#
|
||||||
# DNS
|
# DNS
|
||||||
#
|
#
|
||||||
|
CONFIG_LWIP_DNS_MAX_HOST_IP=1
|
||||||
CONFIG_LWIP_DNS_MAX_SERVERS=3
|
CONFIG_LWIP_DNS_MAX_SERVERS=3
|
||||||
# CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set
|
# CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set
|
||||||
|
# CONFIG_LWIP_DNS_SETSERVER_WITH_NETIF is not set
|
||||||
# end of DNS
|
# end of DNS
|
||||||
|
|
||||||
CONFIG_LWIP_BRIDGEIF_MAX_PORTS=7
|
CONFIG_LWIP_BRIDGEIF_MAX_PORTS=7
|
||||||
@@ -1454,6 +1575,8 @@ CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_NONE=y
|
|||||||
CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
|
CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
|
||||||
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set
|
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set
|
||||||
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set
|
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set
|
||||||
|
CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_NONE=y
|
||||||
|
# CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_CUSTOM is not set
|
||||||
CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y
|
CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y
|
||||||
# CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT is not set
|
# CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT is not set
|
||||||
# CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM is not set
|
# CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM is not set
|
||||||
@@ -1493,6 +1616,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
|
|||||||
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set
|
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set
|
||||||
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set
|
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set
|
||||||
# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set
|
# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set
|
||||||
|
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEPRECATED_LIST is not set
|
||||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200
|
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200
|
||||||
# end of Certificate Bundle
|
# end of Certificate Bundle
|
||||||
|
|
||||||
@@ -1515,6 +1639,7 @@ CONFIG_MBEDTLS_HAVE_TIME=y
|
|||||||
# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
|
# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
|
||||||
CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
|
CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
|
||||||
CONFIG_MBEDTLS_SHA512_C=y
|
CONFIG_MBEDTLS_SHA512_C=y
|
||||||
|
# CONFIG_MBEDTLS_SHA3_C is not set
|
||||||
CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y
|
CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y
|
||||||
# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set
|
# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set
|
||||||
# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set
|
# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set
|
||||||
@@ -1591,6 +1716,7 @@ CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y
|
|||||||
# CONFIG_MBEDTLS_HKDF_C is not set
|
# CONFIG_MBEDTLS_HKDF_C is not set
|
||||||
# CONFIG_MBEDTLS_THREADING_C is not set
|
# CONFIG_MBEDTLS_THREADING_C is not set
|
||||||
CONFIG_MBEDTLS_ERROR_STRINGS=y
|
CONFIG_MBEDTLS_ERROR_STRINGS=y
|
||||||
|
CONFIG_MBEDTLS_FS_IO=y
|
||||||
# end of mbedTLS
|
# end of mbedTLS
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1715,6 +1841,8 @@ CONFIG_SPI_FLASH_HPM_DC_AUTO=y
|
|||||||
# CONFIG_SPI_FLASH_HPM_DC_DISABLE is not set
|
# CONFIG_SPI_FLASH_HPM_DC_DISABLE is not set
|
||||||
CONFIG_SPI_FLASH_SUSPEND_QVL_SUPPORTED=y
|
CONFIG_SPI_FLASH_SUSPEND_QVL_SUPPORTED=y
|
||||||
# CONFIG_SPI_FLASH_AUTO_SUSPEND is not set
|
# CONFIG_SPI_FLASH_AUTO_SUSPEND is not set
|
||||||
|
CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50
|
||||||
|
# CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND is not set
|
||||||
# end of Optional and Experimental Features (READ DOCS FIRST)
|
# end of Optional and Experimental Features (READ DOCS FIRST)
|
||||||
# end of Main Flash configuration
|
# end of Main Flash configuration
|
||||||
|
|
||||||
@@ -1812,6 +1940,11 @@ CONFIG_WS_BUFFER_SIZE=1024
|
|||||||
# Ultra Low Power (ULP) Co-processor
|
# Ultra Low Power (ULP) Co-processor
|
||||||
#
|
#
|
||||||
# CONFIG_ULP_COPROC_ENABLED is not set
|
# CONFIG_ULP_COPROC_ENABLED is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# ULP Debugging Options
|
||||||
|
#
|
||||||
|
# end of ULP Debugging Options
|
||||||
# end of Ultra Low Power (ULP) Co-processor
|
# end of Ultra Low Power (ULP) Co-processor
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1835,16 +1968,23 @@ CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED=y
|
|||||||
# CONFIG_USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT is not set
|
# CONFIG_USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Root Hub configuration
|
# Hub Driver Configuration
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Root Port configuration
|
||||||
#
|
#
|
||||||
CONFIG_USB_HOST_DEBOUNCE_DELAY_MS=250
|
CONFIG_USB_HOST_DEBOUNCE_DELAY_MS=250
|
||||||
CONFIG_USB_HOST_RESET_HOLD_MS=30
|
CONFIG_USB_HOST_RESET_HOLD_MS=30
|
||||||
CONFIG_USB_HOST_RESET_RECOVERY_MS=30
|
CONFIG_USB_HOST_RESET_RECOVERY_MS=30
|
||||||
CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS=10
|
CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS=10
|
||||||
# end of Root Hub configuration
|
# end of Root Port configuration
|
||||||
|
|
||||||
|
# CONFIG_USB_HOST_HUBS_SUPPORTED is not set
|
||||||
|
# end of Hub Driver Configuration
|
||||||
|
|
||||||
CONFIG_USB_OTG_SUPPORTED=y
|
|
||||||
# CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK is not set
|
# CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK is not set
|
||||||
|
CONFIG_USB_OTG_SUPPORTED=y
|
||||||
# end of USB-OTG
|
# end of USB-OTG
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1878,7 +2018,6 @@ CONFIG_WL_SECTOR_SIZE=4096
|
|||||||
#
|
#
|
||||||
CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16
|
CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16
|
||||||
CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
|
CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
|
||||||
# CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION is not set
|
|
||||||
CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y
|
CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y
|
||||||
# CONFIG_WIFI_PROV_STA_FAST_SCAN is not set
|
# CONFIG_WIFI_PROV_STA_FAST_SCAN is not set
|
||||||
# end of Wi-Fi Provisioning Manager
|
# end of Wi-Fi Provisioning Manager
|
||||||
@@ -2229,9 +2368,9 @@ CONFIG_STACK_CHECK_NONE=y
|
|||||||
# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set
|
# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set
|
||||||
CONFIG_ESP32_APPTRACE_DEST_NONE=y
|
CONFIG_ESP32_APPTRACE_DEST_NONE=y
|
||||||
CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y
|
CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y
|
||||||
# CONFIG_MCPWM_ISR_IN_IRAM is not set
|
|
||||||
# CONFIG_EXTERNAL_COEX_ENABLE is not set
|
# CONFIG_EXTERNAL_COEX_ENABLE is not set
|
||||||
# CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set
|
# CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set
|
||||||
|
# CONFIG_MCPWM_ISR_IN_IRAM is not set
|
||||||
# CONFIG_EVENT_LOOP_PROFILING is not set
|
# CONFIG_EVENT_LOOP_PROFILING is not set
|
||||||
CONFIG_POST_EVENTS_FROM_ISR=y
|
CONFIG_POST_EVENTS_FROM_ISR=y
|
||||||
CONFIG_POST_EVENTS_FROM_IRAM_ISR=y
|
CONFIG_POST_EVENTS_FROM_IRAM_ISR=y
|
||||||
|
|||||||
Reference in New Issue
Block a user