Examples and ESP32C3

This commit is contained in:
Armin 2023-09-28 23:15:38 +02:00
parent 480ca42b1a
commit c5f50ea538
28 changed files with 104 additions and 76 deletions

View File

@ -183,26 +183,26 @@ jobs:
# build-properties: # the flags were put in compiler.cpp.extra_flags
# IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
# platform-url: http://drazzy.com/package_drazzy.com_index.json
# required-libraries: ATtinySerialOut
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
# build-properties: # the flags were put in compiler.cpp.extra_flags
# SimpleSender: -DSEND_PWM_BY_TIMER
- arduino-boards-fqbn: ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
platform-url: http://drazzy.com/package_drazzy.com_index.json
required-libraries: ATtinySerialOut
sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
build-properties: # the flags were put in compiler.cpp.extra_flags
SimpleSender: -DSEND_PWM_BY_TIMER
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
# platform-url: http://drazzy.com/package_drazzy.com_index.json
# required-libraries: ATtinySerialOut
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
# build-properties: # the flags were put in compiler.cpp.extra_flags
# SimpleSender: -DSEND_PWM_BY_TIMER
- arduino-boards-fqbn: ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
platform-url: http://drazzy.com/package_drazzy.com_index.json
required-libraries: ATtinySerialOut
sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
build-properties: # the flags were put in compiler.cpp.extra_flags
SimpleSender: -DSEND_PWM_BY_TIMER
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
# platform-url: http://drazzy.com/package_drazzy.com_index.json
# required-libraries: ATtinySerialOut
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
# build-properties: # the flags were put in compiler.cpp.extra_flags
# SimpleSender: -DSEND_PWM_BY_TIMER
- arduino-boards-fqbn: ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
platform-url: http://drazzy.com/package_drazzy.com_index.json
required-libraries: ATtinySerialOut
sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
build-properties: # the flags were put in compiler.cpp.extra_flags
SimpleSender: -DSEND_PWM_BY_TIMER
- arduino-boards-fqbn: MegaCore:avr:128:bootloader=no_bootloader,eeprom=keep,BOD=2v7,LTO=Os_flto,clock=8MHz_internal
platform-url: https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json
@ -284,3 +284,4 @@ jobs:
sketch-names: ${{ matrix.sketch-names }}
sketches-exclude: ${{ matrix.sketches-exclude }}
build-properties: ${{ toJson(matrix.build-properties) }}
cli-version: 0.33.0 # to avoid errors for ATTinyCore

View File

@ -112,9 +112,6 @@
#error "No temperature channel definitions specified for this AVR CPU"
#endif
extern float sVCCVoltage;
extern uint16_t sVCCVoltageMillivolt;
extern long sLastVCCCheckMillis;
extern uint8_t sVCCTooLowCounter;
@ -124,7 +121,6 @@ uint16_t waitAndReadADCChannelWithReference(uint8_t aADCChannelNumber, uint8_t a
uint16_t waitAndReadADCChannelWithReferenceAndRestoreADMUXAndReference(uint8_t aADCChannelNumber, uint8_t aReference);
uint16_t readADCChannelWithOversample(uint8_t aADCChannelNumber, uint8_t aOversampleExponent);
void setADCChannelAndReferenceForNextConversion(uint8_t aADCChannelNumber, uint8_t aReference);
uint16_t readADCChannelWithReferenceOversample(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
uint16_t readADCChannelWithReferenceOversampleFast(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
uint16_t readADCChannelWithReferenceMultiSamples(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aNumberOfSamples);
uint16_t readADCChannelWithReferenceMax(uint8_t aADCChannelNumber, uint8_t aReference, uint16_t aNumberOfSamples);
@ -139,9 +135,7 @@ uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aADCChannelNumber, ui
*/
float getVCCVoltageSimple(void);
void readVCCVoltageSimple(void);
uint16_t getVCCVoltageMillivoltSimple(void);
void readVCCVoltageMillivoltSimple(void);
float getVCCVoltage(void);
void readVCCVoltage(void);
uint16_t getVCCVoltageMillivolt(void);
void readVCCVoltageMillivolt(void);
@ -163,4 +157,17 @@ bool isVCCTooHigh();
bool isVCCTooHighSimple();
#endif // defined(__AVR__) ...
/*
* Variables and functions defined as dummies to allow for seamless compiling on non AVR platforms
*/
extern float sVCCVoltage;
extern uint16_t sVCCVoltageMillivolt;
uint16_t readADCChannelWithReferenceOversample(uint8_t aADCChannelNumber, uint8_t aReference, uint8_t aOversampleExponent);
uint16_t getVCCVoltageMillivoltSimple(void);
float getVCCVoltage(void);
float getCPUTemperature(void);
#endif // _ADC_UTILS_H

View File

@ -688,10 +688,28 @@ float getCPUTemperature(void) {
#endif
}
#elif defined(ARDUINO_ARCH_APOLLO3) // defined(ADC_UTILS_ARE_AVAILABLE)
void ADCUtilsDummyToAvoidBFDAssertions(){
;
}
#else // defined(ADC_UTILS_ARE_AVAILABLE)
// Dummy definition of functions defined in ADCUtils to compile examples without errors
/*
* Persistent storage for VCC value
*/
float sVCCVoltage;
uint16_t sVCCVoltageMillivolt;
uint16_t getVCCVoltageMillivoltSimple(void){
return 3300;
}
uint16_t readADCChannelWithReferenceOversample(uint8_t aChannelNumber __attribute__((unused)),
uint8_t aReference __attribute__((unused)), uint8_t aOversampleExponent __attribute__((unused))) {
return 0;
}
float getCPUTemperature() {
return 20.0;
}
float getVCCVoltage() {
return 3.3;
}
#endif // defined(ADC_UTILS_ARE_AVAILABLE)
#if defined(LOCAL_DEBUG)

View File

@ -131,7 +131,7 @@ void LiquidCrystal_I2C::begin(uint8_t cols __attribute__((unused)), uint8_t line
/********** high level commands, for the user! */
void LiquidCrystal_I2C::clear() {
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
delayMicroseconds(1500); // this command takes a long time! // AJ 20.9.23 1200 is too short for my 2004 LCD's, 1400 is OK
if (_oled)
setCursor(0, 0);
}
@ -274,10 +274,10 @@ void LiquidCrystal_I2C::expanderWrite(uint8_t _data) {
void LiquidCrystal_I2C::pulseEnable(uint8_t _data) {
expanderWrite(_data | En); // En high
delayMicroseconds(1); // enable pulse must be >450ns
// delayMicroseconds(1); // enable pulse must be >450ns // AJ 20.9.23 not required for my LCD's
expanderWrite(_data & ~En); // En low
delayMicroseconds(50); // commands need > 37us to settle
// delayMicroseconds(50); // commands need > 37us to settle // AJ 20.9.23 not required for my LCD's
}
// Alias functions

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -55,31 +55,31 @@
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
#include "ATtinySerialOut.hpp" // Available as Arduino library "ATtinySerialOut"
# if defined(ARDUINO_AVR_DIGISPARKPRO)
#define IR_INPUT_PIN 9 // PA3 - on Digispark board labeled as pin 9
#define IR_RECEIVE_PIN 9 // PA3 - on Digispark board labeled as pin 9
# else
#define IR_INPUT_PIN 0 // PCINT0
#define IR_RECEIVE_PIN 0 // PCINT0
# endif
# elif defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__)
#define IR_INPUT_PIN 10
#define IR_RECEIVE_PIN 10
# elif (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
#define IR_INPUT_PIN 21 // INT0
#define IR_RECEIVE_PIN 21 // INT0
# elif defined(ESP8266)
#define IR_INPUT_PIN 14 // D5
#define IR_RECEIVE_PIN 14 // D5
# elif defined(ESP32)
#define IR_INPUT_PIN 15
#define IR_RECEIVE_PIN 15
# elif defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_MBED_NANO)
#define IR_INPUT_PIN 3 // GPIO15 Use pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
#define IR_RECEIVE_PIN 3 // GPIO15 Use pin 3 since pin 2|GPIO25 is connected to LED on Pi pico
# elif defined(ARDUINO_ARCH_RP2040) // Pi Pico with arduino-pico core https://github.com/earlephilhower/arduino-pico
#define IR_INPUT_PIN 15 // to be compatible with the Arduino Nano RP2040 Connect (pin3)
#define IR_RECEIVE_PIN 15 // to be compatible with the Arduino Nano RP2040 Connect (pin3)
# else
#define IR_INPUT_PIN 2 // INT0
#define IR_RECEIVE_PIN 2 // INT0
# endif
#elif defined(USE_IRMP_LIBRARY)
/*
* IRMP version
*/
#define IR_INPUT_PIN 2
#define IR_RECEIVE_PIN 2
#define IRMP_USE_COMPLETE_CALLBACK 1 // Enable callback functionality. It is required if IRMP library is used.
#if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN)
#define FEEDBACK_LED_PIN ALTERNATIVE_IR_FEEDBACK_LED_PIN
@ -159,7 +159,7 @@ void setup() {
IRDispatcher.init(); // This just calls irmp_init()
#if defined(USE_TINY_IR_RECEIVER)
Serial.println(F("Ready to receive NEC IR signals at pin " STR(IR_INPUT_PIN)));
Serial.println(F("Ready to receive NEC IR signals at pin " STR(IR_RECEIVE_PIN)));
#else
irmp_register_complete_callback_function(&handleReceivedIRData); // fixed function in IRCommandDispatcher.hpp

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -33,8 +33,8 @@
#include <Arduino.h>
#define IR_INPUT_PIN 2
//#define IR_INPUT_PIN 3
#define IR_RECEIVE_PIN 2
//#define IR_RECEIVE_PIN 3
/*
* Helper macro for getting a macro definition as string
@ -55,19 +55,19 @@ void setup()
Serial.println(F("START " __FILE__ " from " __DATE__));
#if defined(EICRA) && defined(EIFR) && defined(EIMSK)
# if (IR_INPUT_PIN == 2)
# if (IR_RECEIVE_PIN == 2)
EICRA |= _BV(ISC00); // interrupt on any logical change
EIFR |= _BV(INTF0); // clear interrupt bit
EIMSK |= _BV(INT0); // enable interrupt on next change
# elif (IR_INPUT_PIN == 3)
# elif (IR_RECEIVE_PIN == 3)
EICRA |= _BV(ISC10); // enable interrupt on pin3 on both edges for ATmega328
EIFR |= _BV(INTF1); // clear interrupt bit
EIMSK |= _BV(INT1); // enable interrupt on next change
# endif
#else
attachInterrupt(digitalPinToInterrupt(IR_INPUT_PIN), measureTimingISR, CHANGE);
attachInterrupt(digitalPinToInterrupt(IR_RECEIVE_PIN), measureTimingISR, CHANGE);
#endif
Serial.println(F("Ready to analyze NEC IR signal at pin " STR(IR_INPUT_PIN)));
Serial.println(F("Ready to analyze NEC IR signal at pin " STR(IR_RECEIVE_PIN)));
Serial.println();
}
@ -197,9 +197,9 @@ void loop()
void IRAM_ATTR measureTimingISR()
#else
# if defined(EICRA) && defined(EIFR) && defined(EIMSK)
# if (IR_INPUT_PIN == 2)
# if (IR_RECEIVE_PIN == 2)
ISR(INT0_vect)
# elif (IR_INPUT_PIN == 3)
# elif (IR_RECEIVE_PIN == 3)
ISR(INT1_vect)
# endif
# else
@ -213,7 +213,7 @@ void measureTimingISR()
/*
* read level and give feedback
*/
uint8_t tInputLevel = digitalRead(IR_INPUT_PIN);
uint8_t tInputLevel = digitalRead(IR_RECEIVE_PIN);
digitalWrite(LED_BUILTIN, !tInputLevel);
if (tMicrosDelta > 10000)

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -174,7 +174,7 @@
#define TONE_PIN 42 // Dummy for examples using it
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define IR_INPUT_PIN 8
#define IR_RECEIVE_PIN 8
#define IR_SEND_PIN 9
#define TONE_PIN 10 // ADC2_0
#define APPLICATION_PIN 11

View File

@ -39,11 +39,6 @@
//#define LOCAL_DEBUG // This enables debug output only for this file
#endif
/*
* Check for additional characteristics of timing like length of mark for a constant mark protocol,
* where space length determines the bit value. Requires up to 194 additional bytes of program memory.
*/
//#define DECODE_STRICT_CHECKS
/** \addtogroup Receiving Receiving IR data for multiple protocols
* @{
*/

View File

@ -94,6 +94,7 @@ union LongUnion {
int16_t Words[2];
uint32_t ULong;
int32_t Long;
float Float;
};
#endif // _LONG_UNION_H
@ -140,6 +141,12 @@ union LongLongUnion {
int16_t Words[4];
uint64_t ULongLong;
int64_t LongLong;
#if __DBL_MANT_DIG__== 24
float Floats[2]; // 32 bit double, as for AVR
#else
// 64 bit double
double Double;
#endif
};
#endif // _LONG_LONG_UNION_H