major changes to the backend for controlling the ESP8266 ColorChord.
A new challenger has arrived. It looks like basically... any network traffic causes glitches in the ADC in. Not sure how to attack that yet.
This commit is contained in:
parent
666d8077ab
commit
c4669ce825
12 changed files with 693 additions and 56 deletions
|
@ -13,11 +13,14 @@
|
|||
#include "http.h"
|
||||
#include "spi_flash.h"
|
||||
#include "esp8266_rom.h"
|
||||
#include <gpio.h>
|
||||
#include "flash_rewriter.h"
|
||||
|
||||
static struct espconn *pUdpServer;
|
||||
static struct espconn *pHTTPServer;
|
||||
struct espconn *pespconn;
|
||||
uint16_t g_gpiooutputmask = 0;
|
||||
|
||||
|
||||
static int need_to_switch_back_to_soft_ap = 0; //0 = no, 1 = will need to. 2 = do it now.
|
||||
#define MAX_STATIONS 20
|
||||
|
@ -64,6 +67,7 @@ static void ICACHE_FLASH_ATTR scandone(void *arg, STATUS status)
|
|||
int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata, unsigned short len)
|
||||
{
|
||||
char * buffend = buffer;
|
||||
pusrdata[len] = 0;
|
||||
|
||||
switch( pusrdata[0] )
|
||||
{
|
||||
|
@ -271,8 +275,68 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
|
|||
}
|
||||
return buffend - buffer;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
case 'G': case 'g':
|
||||
{
|
||||
static const uint32_t AFMapper[16] = {
|
||||
0, PERIPHS_IO_MUX_U0TXD_U, 0, PERIPHS_IO_MUX_U0RXD_U,
|
||||
0, 0, 1, 1,
|
||||
1, 1, 1, 1,
|
||||
PERIPHS_IO_MUX_MTDI_U, PERIPHS_IO_MUX_MTCK_U, PERIPHS_IO_MUX_MTMS_U, PERIPHS_IO_MUX_MTDO_U };
|
||||
|
||||
int nr = my_atoi( &pusrdata[2] );
|
||||
|
||||
|
||||
if( AFMapper[nr] == 1 )
|
||||
{
|
||||
buffend += ets_sprintf( buffend, "!G%c%d\n", pusrdata[1], nr );
|
||||
return buffend - buffer;
|
||||
}
|
||||
else if( AFMapper[nr] )
|
||||
{
|
||||
PIN_FUNC_SELECT( AFMapper[nr], 3); //Select AF pin to be GPIO.
|
||||
}
|
||||
|
||||
switch( pusrdata[1] )
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
GPIO_OUTPUT_SET(GPIO_ID_PIN(nr), pusrdata[1]-'0' );
|
||||
buffend += ets_sprintf( buffend, "G%c%d", pusrdata[1], nr );
|
||||
g_gpiooutputmask |= (1<<nr);
|
||||
break;
|
||||
case 'i': case 'I':
|
||||
GPIO_DIS_OUTPUT(GPIO_ID_PIN(nr));
|
||||
buffend += ets_sprintf( buffend, "GI%d\n", nr );
|
||||
g_gpiooutputmask &= ~(1<<nr);
|
||||
break;
|
||||
case 'f': case 'F':
|
||||
{
|
||||
int on = GPIO_INPUT_GET( GPIO_ID_PIN(nr) );
|
||||
on = !on;
|
||||
GPIO_OUTPUT_SET(GPIO_ID_PIN(nr), on );
|
||||
g_gpiooutputmask |= (1<<nr);
|
||||
buffend += ets_sprintf( buffend, "GF%d:%d\n", nr, on );
|
||||
break;
|
||||
}
|
||||
case 'g': case 'G':
|
||||
buffend += ets_sprintf( buffend, "GG%d:%d\n", nr, GPIO_INPUT_GET( GPIO_ID_PIN(nr) ) );
|
||||
break;
|
||||
case 's': case 'S':
|
||||
{
|
||||
uint32_t rmask = 0;
|
||||
int i;
|
||||
for( i = 0; i < 16; i++ )
|
||||
{
|
||||
rmask |= GPIO_INPUT_GET( GPIO_ID_PIN(i) )?(1<<i):0;
|
||||
}
|
||||
buffend += ets_sprintf( buffend, "GS:%d:%d\n", g_gpiooutputmask, rmask );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return buffend - buffer;
|
||||
}
|
||||
case 'c': case 'C':
|
||||
return CustomCommand( buffer, retsize, pusrdata, len);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -307,7 +371,6 @@ void ICACHE_FLASH_ATTR CSInit()
|
|||
espconn_regist_connectcb(pHTTPServer, httpserver_connectcb);
|
||||
espconn_accept(pHTTPServer);
|
||||
espconn_regist_time(pHTTPServer, 15, 0); //timeout
|
||||
|
||||
}
|
||||
|
||||
void CSTick( int slowtick )
|
||||
|
|
|
@ -11,14 +11,19 @@
|
|||
//NOTE: It is SAFE to use pusrdata and retdata as the same buffer.
|
||||
int ICACHE_FLASH_ATTR issue_command(char * retdata, int retsize, char *pusrdata, unsigned short len);
|
||||
|
||||
|
||||
//Includes UDP Control + HTTP Interfaces
|
||||
void ICACHE_FLASH_ATTR CSInit();
|
||||
void ICACHE_FLASH_ATTR CSTick( int slowtick );
|
||||
|
||||
//You must provide:
|
||||
//Critical should not lock interrupts, just disable services that have problems
|
||||
//with double-interrupt faults. I.e. turn off/on any really fast timer interrupts.
|
||||
//These generally only get called when doing serious operations like reflashing.
|
||||
void EnterCritical();
|
||||
void ExitCritical();
|
||||
|
||||
//If we receive a command that's not F, E or W (Flash Echo Wifi)
|
||||
int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, unsigned short len);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -62,6 +62,13 @@ void Uint32To10Str( char * out, uint32 dat )
|
|||
out[place] = 0;
|
||||
}
|
||||
|
||||
char tohex1( uint8_t i )
|
||||
{
|
||||
i = i&0x0f;
|
||||
return (i<10)?('0'+i):('a'-10+i);
|
||||
}
|
||||
|
||||
|
||||
void ICACHE_FLASH_ATTR EndTCPWrite( struct espconn * conn )
|
||||
{
|
||||
if(generic_ptr!=generic_buffer)
|
||||
|
|
|
@ -17,6 +17,8 @@ extern const char * enctypes[6];// = { "open", "wep", "wpa", "wpa2", "wpa_wpa2",
|
|||
|
||||
#define printf( ... ) ets_sprintf( generic_print_buffer, __VA_ARGS__ ); uart0_sendStr( generic_print_buffer );
|
||||
|
||||
char tohex1( uint8_t i );
|
||||
|
||||
int32 my_atoi( const char * in );
|
||||
void Uint32To10Str( char * out, uint32 dat );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue