From 60bb0ffb4c56fa39b01310f7a2a23090364bc3e0 Mon Sep 17 00:00:00 2001 From: Andrew Allen Date: Sat, 3 Sep 2016 20:51:23 -0700 Subject: [PATCH 1/2] add adc function --- compat.h | 3 +++ lisp.c | 7 ++++++- tlisp.ccc | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) mode change 100644 => 100755 compat.h mode change 100644 => 100755 lisp.c mode change 100644 => 100755 tlisp.ccc diff --git a/compat.h b/compat.h old mode 100644 new mode 100755 index 8f92647..4ee170f --- a/compat.h +++ b/compat.h @@ -111,6 +111,7 @@ void httpd_loop(int s); void gpio_enable(int pin, int state); void gpio_write(int pin, int value); int gpio_read(int pin); + int sdk_system_adc_read(); // flash simulation in RAM #define SPI_FLASH_RESULT_OK 0 @@ -128,6 +129,8 @@ void httpd_loop(int s); #define flash_memory ((unsigned char*)(0x40200000 + FS_ADDRESS)) + #include + #include #include "esp_spiffs.h" #include "spiffs.h" diff --git a/lisp.c b/lisp.c old mode 100644 new mode 100755 index abd18a3..b7d73da --- a/lisp.c +++ b/lisp.c @@ -833,6 +833,11 @@ PRIM dht(lisp pin) { return cons(mkint(t), mkint(h)); } +PRIM adc() { + int v = sdk_system_adc_read(); + return mkint(v); +} + // CONTROL INTERRUPTS: // ------------------- // (interrupt PIN 0) : disable @@ -1996,7 +2001,6 @@ PRIM printf_(lisp *envp, lisp all) { char type = *p++ = *f++; switch (type) { case '%': - putchar('%'); break; case 's': princ(car(all)); break; case 'S': @@ -3366,6 +3370,7 @@ lisp lisp_init() { DEFPRIM(in, 1, in); DEFPRIM(dht, 1, dht); DEFPRIM(interrupt, 2, interrupt); + DEFPRIM(adc, 0, adc); // system stuff DEFPRIM(gc, -1, gc); diff --git a/tlisp.ccc b/tlisp.ccc old mode 100644 new mode 100755 index 30e4409..71f6538 --- a/tlisp.ccc +++ b/tlisp.ccc @@ -24,6 +24,7 @@ void gpio_enable(int pin, int state) {} void gpio_write(int pin, int value) {} int gpio_read(int pin) { return 0; } +int sdk_system_adc_read() { return 777; } void interrupt_init (int pin, int changeType) {} int getInterruptCount(int pin, int mode) { return -1; } From 3d8a32f09eea0a7c0d05d2f809b80a52435b00e6 Mon Sep 17 00:00:00 2001 From: Andrew Allen Date: Sat, 3 Sep 2016 21:24:07 -0700 Subject: [PATCH 2/2] add back inadvertently removed line --- lisp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp.c b/lisp.c index b7d73da..847e75f 100755 --- a/lisp.c +++ b/lisp.c @@ -2001,6 +2001,7 @@ PRIM printf_(lisp *envp, lisp all) { char type = *p++ = *f++; switch (type) { case '%': + putchar('%'); break; case 's': princ(car(all)); break; case 'S':