add Analog Functionality

This commit is contained in:
Siwat Sirichai 2023-08-27 23:42:08 +07:00
parent 94443393d0
commit 1e4e8f7347
4 changed files with 57 additions and 12 deletions

View file

@ -7,6 +7,7 @@
#include <PCF8574.h>
#ifdef ANALOG_CARD_ENABLE
#include <Adafruit_ADS1X15.h>
#include <MCP4725.h>
#endif
#define INPUT_BANK_A_ADDRESS 0x21
@ -14,8 +15,12 @@
#define PWM_BANK_ADDRESS 0x5F
#define OUTPUT_BANK_ADDRESS 0x21
#define EEPROM_ADDRESS 0x22
#define ANALOG_INPUT_BANK_A_ADDRESS 0x60
#define ANALOG_INPUT_BANK_B_ADDRESS 0x61
#define ANALOG_INPUT_BANK_A_ADDRESS 0x48
#define ANALOG_INPUT_BANK_B_ADDRESS 0x49
#define DAC0_ADDRESS 0x60
#define DAC1_ADDRESS 0x61
#define DAC2_ADDRESS 0x62
#define DAC3_ADDRESS 0x63
//#define USE_INTERRUPT
#define INPUT_BANK_A_INTERRUPT 36
@ -71,7 +76,15 @@ void IRAM_ATTR refreshInputBankB();
* @param id The number of the pin to be read
* @return The value of the pin (0-4095)
*/
uint16_t ESPMega_analogRead(int id);
int16_t ESPMega_analogRead(int id);
/**
* Write a True Analog Signal to one of the ESPMega Analog Card's
* Analog Output pins (AO0-AO3)
*
* @param id The number of the pin to write to
* @param value the analog value of the pin (0-4095)
*/
void ESPMega_dacWrite(int id, int value);
#endif
#endif