Hardware
Unicorn Seat mini Development Board V1.4
Embedded Software
Onenet_demo_esp8266_edp_led
Project Modification Content
LED.C File Modification
Function Led_init,mini Development Board LEDs are located in Gpio PB6, PB7, PB8, PB9
Function Led_getvalue,mini Development Board LED status opposite IO port status
/**
* @brief LED Indicator initialization function
**/
voidLed_init (void
{
Gpio_inittypedefGpio_initstructure;
pb9--corresponding Development Board red indicator; pb8--corresponding Development Board green indicator;
pb7--corresponding Development Board yellow indicator; PB6---Corresponding Development Board blue indicator
Rcc_apb2periphclockcmd (RCC_APB2PERIPH_GPIOB,ENABLE);
Gpio_initstructure.Gpio_pin=Gpio_pin_6|Gpio_pin_7|Gpio_pin_8|Gpio_pin_9;
Gpio_initstructure.Gpio_speed=Gpio_speed_50mhz;
Gpio_initstructure.Gpio_mode=GPIO_MODE_OUT_PP;
Gpio_init (GPIOB,&Gpio_initstructure);
}
?
/**
* @brief Get the current status value of the LED
**/
voidLed_getvalue (void
{
IfGpio_readoutputdatabit (GPIOB,Gpio_pin_9))
{
Red_value=0;
}
Else
{
Red_value=1;
}
IfGpio_readoutputdatabit (GPIOB,Gpio_pin_6))
{
Blue_value=0;
}
Else
{
Blue_value=1;
}
IfGpio_readoutputdatabit (GPIOB,Gpio_pin_8))
{
Green_value=0;
}
Else
{
Green_value=1;
}
IfGpio_readoutputdatabit (GPIOB,gpio_pin_7))
{
yellow_value=0;
}
else
{
Span class= "Cm-tab" > yellow_value=1;
}
}
?
Led.h File Modification
#define Led_red_off gpio_setbits (gpiob,gpio_pin_9)
#define Led_green_off gpio_setbits (gpiob,gpio_pin_8)
#define Led_yellow_off Gpio_setbits (gpiob,gpio_pin_7)
#define Led_blue_off Gpio_setbits (gpiob,gpio_pin_6)
?
#define LED_RED_ON gpio_resetbits (gpiob,gpio_pin_9)
#define LED_GREEN_ON gpio_resetbits (gpiob,gpio_pin_8)
#define LED_YELLOW_ON gpio_resetbits (gpiob,gpio_pin_7)
#define LED_BLUE_ON gpio_resetbits (gpiob,gpio_pin_6)
ESP8266.h File Modification
#define DEVICEID "XXXXXX"
#define APIKEY "Xxxxxxxxxxxxxxxxxx"
#define CWJAP "at+cwjap=\" xxxxxxxx\ ", \" xxxxxxx\ "\ r \ n"
top two macros define Onenet platform-related, last WiFi SSID name and password, these three macros are modified according to their needs
onenet Platform Operation
Set GPIO status
The above command realizes the bright blue led.
Read GPIO status
Currently showing blue lit, other three LEDs off
Reference
1. https://github.com/cm-heclouds/OneNET_demo_code_kylin/tree/master/OneNET_Demo_ESP8266_EDP_Led
2. Https://github.com/cm-heclouds/OneNET_demo_code_kylin/blob/master/OneNET_Demo_User_Guide.pdf
Onenet read and control the LED status on the development of Kylin seat