20 #include "AudioConfig.h"
25 # define PSTR(fmt) fmt
29 # define PI 3.14159265359f
41 # define INPUT_PULLUP 0x2
54 enum PrintCharFmt {DEC, HEX};
61 virtual size_t write(uint8_t ch){
66 virtual size_t write(
const char *str) {
67 return write((
const uint8_t *)str, strlen(str));
70 virtual size_t write(
const char *buffer,
size_t size) {
71 return write((
const uint8_t *)buffer, size);
74 virtual int print(
const char* msg){
75 int result = strlen(msg);
76 return write(msg, result);
79 virtual int println(
const char* msg=
"") {
80 int result = print(msg);
85 virtual int print(
int number){
87 snprintf(buffer,80,
"%d", number);
91 virtual int print(
char c, PrintCharFmt spec){
95 snprintf(result, 3,
"%c", c);
98 snprintf(result, 3,
"%x", c);
106 virtual size_t write(
const uint8_t *data,
size_t len){
107 if (data ==
nullptr)
return 0;
108 for (
size_t j=0;j<len;j++){
115 virtual int availableForWrite() {
return 1024; }
118 virtual void flush() { }
127 virtual int available(){
return 0;}
128 virtual size_t readBytes(uint8_t* data,
size_t len) {
return 0;}
130 virtual int read(){
return -1;}
131 virtual int peek(){
return -1;}
132 virtual void setTimeout(
size_t t){}
142 virtual int read(uint8_t* buffer,
size_t len) {
return 0;};
143 virtual int read() {
return 0; };
144 bool connected() {
return false;};
145 bool connect(
const char* ip,
int port) {
return false;}
146 virtual operator bool() {
return false;}
151 size_t write(uint8_t ch)
override {
154 virtual operator bool() {
162 inline long map(
long x,
long in_min,
long in_max,
long out_min,
long out_max) {
163 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
204 #include "driver/gpio.h"
207 printf(
"digitalRead:%d\n", pin);
208 return gpio_get_level((gpio_num_t)pin);
211 void pinMode(
int pin,
int mode) {
212 gpio_num_t gpio_pin=(gpio_num_t)pin;
213 printf(
"pinMode(%d,%d)\n", pin, mode);
215 gpio_reset_pin(gpio_pin);
218 gpio_set_direction(gpio_pin, GPIO_MODE_INPUT);
221 gpio_set_direction(gpio_pin, GPIO_MODE_OUTPUT);
224 gpio_set_direction(gpio_pin, GPIO_MODE_INPUT);
225 gpio_set_pull_mode(gpio_pin, GPIO_PULLUP_ONLY);
228 gpio_set_direction(gpio_pin, GPIO_MODE_INPUT_OUTPUT);
int digitalRead(int pin)
e.g. for AudioActions
Definition: NoArduino.h:206
void stop()
Public generic methods.
Definition: AudioRuntime.h:27