Fixed and tested digitalRead with Value Display application widget

master
maxxir 7 years ago
parent ddef579714
commit f4dac80475

@ -424,13 +424,17 @@ void processCmd(uint8_t * buff, size_t len)
if(!strcmp(cmd, "dr")) // digital pin read
{
rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d ", pin, digitalRead(pin));
//This is bug on LPc13xx original sources, last space symbol is unnecessary
//rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d ", pin, digitalRead(pin));
rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d", pin, digitalRead(pin));
replacetonull(rsp_mem, ' ');
sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0);
}
else if(!strcmp(cmd, "ar")) // analog pin read
{
rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d ", pin, analogRead(pin));
//This is bug on LPc13xx original sources, last space symbol is unnecessary (as I think..)
//rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d ", pin, analogRead(pin));
rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d", pin, analogRead(pin));
replacetonull(rsp_mem, ' ');
sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0);
}

@ -43,7 +43,9 @@
//#define BLYNK_INFO_CPU "ST103FRB"
#endif
*/
#define BLYNK_INFO_CPU "ATmega2560"
#define BLYNK_INFO_CPU "ATmega1284"
//#define BLYNK_INFO_CPU "ATmega2560"
//#define BLYNK_INFO_CPU "ATmega328P"
#endif
#ifndef BLYNK_INFO_CONNECTION

@ -20,6 +20,15 @@ uint8_t digitalRead(uint8_t pin)
val = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]);
#else
PRINTF("digital pin %d read\r\n", pin);
if(pin == 21)
{
val = sw1_read()?0:!0;
PRINTF("SW1 is: %d %s\r\n", val, val?"HIGH":"LOW");
}
else
{
val = 1;
}
#endif
return val;
}
@ -36,7 +45,7 @@ void digitalWrite(uint8_t pin, uint8_t val)
else if(val == LOW) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low
#else
PRINTF("digital pin %d write val %d\r\n", pin, val);
if(pin == 13)
if(pin == 20)
{
if(val == 0)
{
@ -98,11 +107,16 @@ void pinMode(uint8_t pin, pinmode_dir dir)
else if(dir == OUTPUT) Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output
#else
PRINTF("pinmode setting: pin %d dir %d\r\n", pin, dir);
if((pin == 13)&&(dir ==1))
if((pin == 20)&&(dir ==1))
{
//m1284p LED1 pin to out
led1_conf();
}
else if((pin == 21)&&(dir == 0))
{
//m1284p SW1 pin to input
sw1_conf();
}
#endif
}

@ -58,9 +58,9 @@ uint8_t Domain_IP[4] = {0, }; // Translated IP address by DNS S
* OK (v1.2) Add DNS resolve before BLYNK app running to <blynk-cloud.com>
* OK (v1.1) Add LED_ON/LED_OFF handle on LED D13 BLYNK Android application
* GPIO OUT - works OK (look ./Application/Blynk/blynkDependency.c digitalWrite(..) && pinMode(..))!
* OK Add printout <blynk> server metrics on start-up
* OK(v1.2) Add printout <blynk> server metrics on start-up
* Need to try next:
* GPIO IN (via virtual pins?)
* OK (v1.3)GPIO IN - fixed bug (remove redundant space symbol in <dw xx xx >)
* Virtual IN/OUT
* Analog Read/Write
* Restore pins state on board reboot
@ -100,7 +100,7 @@ volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days
//*********Program metrics
const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции
const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции
const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.2 Static IP BLYNK WIZNET_5500 ETHERNET 12/03/2019\r\n"; // Program name
const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.3 Static IP BLYNK WIZNET_5500 ETHERNET 12/03/2019\r\n"; // Program name
#if defined(__AVR_ATmega128__)
const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128