Skip to content

Commit 7f3fde1

Browse files
author
Stefan
committed
Added camera command
1 parent 192987d commit 7f3fde1

File tree

5 files changed

+79
-4
lines changed

5 files changed

+79
-4
lines changed

Basic2/Posix/basic.c

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ const char shelp[] PROGMEM = "HELP";
232232
const char sshl[] PROGMEM = "<<";
233233
const char sshr[] PROGMEM = ">>";
234234
const char sbit[] PROGMEM = "BIT";
235+
#ifdef HASCAMERA
236+
const char scam[] PROGMEM = "CAM";
237+
#endif
235238

236239

237240
/* zero terminated keyword storage */
@@ -315,6 +318,9 @@ const char* const keyword[] PROGMEM = {
315318
shelp,
316319
#endif
317320
sshl, sshr, sbit,
321+
#ifdef HASCAMERA
322+
scam,
323+
#endif
318324
0
319325
};
320326

@@ -396,6 +402,9 @@ const token_t tokens[] PROGMEM = {
396402
THELP,
397403
#endif
398404
TSHL, TSHR, TBIT,
405+
#ifdef HASCAMERA
406+
TCAM,
407+
#endif
399408
0
400409
};
401410

@@ -7065,6 +7074,30 @@ void xhelp() {
70657074
}
70667075
}
70677076

7077+
/*
7078+
* The camera control command for ESP32 cameras and similar MCU cams
7079+
* currently only a stub, no functionality, just to shape the syntax
7080+
*/
7081+
7082+
void xcam() {
7083+
nexttoken();
7084+
switch(token) {
7085+
case TGET: /* get an image from the camera to the buffer */
7086+
nexttoken();
7087+
cameraget();
7088+
break;
7089+
case TSET: /* set the camera parameters */
7090+
nexttoken();
7091+
cameraset();
7092+
break;
7093+
case TSAVE: /* save the image to the filesystem */
7094+
nexttoken();
7095+
camerasave();
7096+
break;
7097+
}
7098+
while(!termsymbol()) nexttoken();
7099+
}
7100+
70687101
/*
70697102
NEW the general cleanup function - new deletes everything
70707103
@@ -8588,6 +8621,15 @@ void xwire() {
85888621

85898622
nexttoken();
85908623
#if defined(HASWIRE) || defined(HASSIMPLEWIRE)
8624+
/* a stop causes a release of the bus, can be used after multiple one byte writes
8625+
currently part of the cycle */
8626+
/*
8627+
if (token == STOP) {
8628+
wirestop();
8629+
return;
8630+
}
8631+
*/
8632+
85918633
parsearguments();
85928634
if (!USELONGJUMP && er) return;
85938635

@@ -8606,7 +8648,7 @@ void xwire() {
86068648

86078649
void xfwire() {
86088650
#if defined(HASWIRE) || defined(HASSIMPLEWIRE)
8609-
uint8_t port;
8651+
int port;
86108652
ioer=0;
86118653
port=pop();
86128654
if (!USELONGJUMP && er) return;
@@ -10543,6 +10585,11 @@ void statement() {
1054310585
case THELP:
1054410586
xhelp();
1054510587
break;
10588+
#endif
10589+
#ifdef HASCAMERA
10590+
case TCAM:
10591+
xcam();
10592+
break;
1054610593
#endif
1054710594
default:
1054810595
/* strict syntax checking */

Basic2/Posix/basic.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@
220220
* Extension tokens can be in the range from -128 upwards.
221221
* one needs to set HASLONGTOKENS. Currently ony one set of
222222
* extension tokens is implemented ranging from -128 to -255.
223-
*
224-
* **** right now unused and untested **** */
223+
*/
224+
225+
#define TCAM -128
225226

226227
/* BASEKEYWORD is used by the lexer. From this keyword on it tries to match. */
227228
#define BASEKEYWORD -121
@@ -821,6 +822,9 @@ void xendswitch();
821822
/* the editor */
822823
void xedit();
823824

825+
/* camera support with a meta command */
826+
void xcam();
827+
824828
/* the statement loop */
825829
void statement();
826830

Basic2/Posix/hardware.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
* POSIXMQTT: analogous to ARDUINOMQTT, send and receive MQTT messages (unfinished)
5252
* POSIXWIRING: use the (deprectated) wiring code for gpio on Raspberry Pi
5353
* POSIXPIGPIO: use the pigpio library on a Raspberry PI - currently broken - wire change - don't use
54+
* ESP32CAMERA: a stub to help with development of the MCU code
5455
*/
5556

5657
#define POSIXTERMINAL
@@ -62,6 +63,7 @@
6263
#undef POSIXMQTT
6364
#undef POSIXWIRING
6465
#undef POSIXPIGPIO
66+
#define ESP32CAMERA
6567

6668
/* simulates SPI RAM, only test code, keep undefed if you don't want to do something special */
6769
#undef SPIRAMSIMULATOR
@@ -205,6 +207,11 @@ unsigned long millis();
205207
*/
206208
#undef HASRF24
207209

210+
/* the camera development helper */
211+
#ifdef ESP32CAMERA
212+
#define HASCAMERA
213+
#endif
214+
208215
/*
209216
* Tell BASIC we have MQTT
210217
*/

Basic2/Posix/language.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@
128128
#define HASFULLINSTR
129129
#define HASLOOPOPT
130130
#define HASNUMSYSTEM
131+
#define HASCAMERA
131132
#endif
132133

133-
134134
/*
135135
*
136136
* Odd stuff - these things change the behaviour of BASIC in some aspects.
@@ -204,6 +204,7 @@
204204
#undef HASNUMSYSTEM
205205
#undef HASPOWER
206206
#undef HASUSRCALL
207+
#undef HASCAMERA
207208
#endif
208209

209210
/* the original Palo Alto Tinybasic, this is the real minimum */
@@ -239,6 +240,7 @@
239240
#undef HASNUMSYSTEM
240241
#undef HASPOWER
241242
#undef HASUSRCALL
243+
#undef HASCAMERA
242244
#endif
243245

244246
/* all features minus float and tone */
@@ -269,6 +271,7 @@
269271
#define HASFULLINSTR
270272
#define HASLOOPOPT
271273
#define HASNUMSYSTEM
274+
#undef HASCAMERA
272275
#endif
273276

274277
/* a simple integer basic for small systems mainly the UNO */
@@ -301,6 +304,7 @@
301304
#undef HASNUMSYSTEM
302305
#undef HASPOWER
303306
#undef HASUSRCALL
307+
#undef HASCAMERA
304308
#endif
305309

306310
/* a small integer BASIC for 32kB systems with big cores */
@@ -333,6 +337,7 @@
333337
#undef HASNUMSYSTEM
334338
#undef HASPOWER
335339
#undef HASUSRCALL
340+
#undef HASCAMERA
336341
#endif
337342

338343

@@ -364,6 +369,7 @@
364369
#define HASFULLINSTR
365370
#define HASLOOPOPT
366371
#define HASNUMSYSTEM
372+
#define HASCAMERA
367373
#endif
368374

369375
/* a simple BASIC with float support */
@@ -396,6 +402,7 @@
396402
#undef HASNUMSYSTEM
397403
#undef HASPOWER
398404
#undef HASUSRCALL
405+
#undef HASCAMERA
399406
#endif
400407

401408
/* a Tinybasic with float support */
@@ -428,6 +435,7 @@
428435
#undef HASNUMSYSTEM
429436
#undef HASPOWER
430437
#undef HASUSRCALL
438+
#undef HASCAMERA
431439
#endif
432440

433441
/*
@@ -462,3 +470,8 @@
462470
#if !defined(DISPLAYHASGRAPH)
463471
#undef HASGRAPH
464472
#endif
473+
474+
/* the camera sits in the long token space */
475+
#if defined(HASCAMERA)
476+
#define HASLONGTOKENS
477+
#endif

Basic2/Posix/runtime.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,10 @@ char radioread() { return 0; }
21502150
void sensorbegin() {}
21512151
float sensorread(uint8_t s, uint8_t v) {return 0;};
21522152

2153+
/* the camera - a stub to help with development */
2154+
#ifdef HASCAMERA
2155+
#include "src/Runtime/esp32cam.h"
2156+
#endif
21532157

21542158
/*
21552159
* event handling wrappers, to keep Arduino specifics out of BASIC

0 commit comments

Comments
 (0)