Forwarded from RT-Thread Community Developer JQRR_7669
Quick Led is designed to provide a quick and easy-to-use led drive pack.
qled
├───inc // Header file category
│ | qled.h // API header file
│ └───qled_sample.h // Sample header file
├───src // Souce code category
│ | qled.c // Mian module
│ └───qled_samplec // Sample module
│ license // Package license
│ readme.md // Package Instruction
└───SConscript // RT-Thread default script construction
Quick Led package applies LGPLv2.1 license, for more details please check the LICENSE
file.
qled_add(24, 1);//Add the No.24 pin led to the drive, high level lit on
qled_set_blink(24, 50, 50);//Set the led to flash at 10Hz, light 50ms, off 50ms
rt_thread_mdelay(5000);// 5s
qled_set_blink(24, 50, 450);//Set the led to flash at 2Hz, light 50ms, off 50ms
rt_thread_mdelay(10000);//10s
qled_remove(24);//The led is no longer needed and removed from the drive
#define QLED_SOS_PIN GET_PIN(B, 9) //No.25
static int sos_send_times = 0;//Count of the number of sos signals sent
static const u16 sos_datas[] = //Define the sos signal time data
{
200, 200, 200, 200, 200, 200, //short 3 times
600, 600, 600, 600, 600, 600, //long 3 times
200, 200, 200, 200, 200, 200 + 2000 //short 3 times and 2000ms interval
};
static void qled_sos_cb(void)//Define special sequences, execution ends, callback functions
{
sos_send_times--;
if (sos_send_times > 0)//The number of executions did not reach
{
qled_set_special(QLED_SOS_PIN, sos_datas, sizeof(sos_datas)/sizeof(u16), qled_sos_cb);//Execute again
}
else//Execute completed
{
qled_remove(QLED_SOS_PIN);//No longer needed, remove from the driver
}
}
void qled_send_sos(void)//The execution sends the sos signal, sends the SOS signal 5 times, and takes a total of 40s
{
sos_send_times = 5;//Set the number of sends to 5
qled_add(QLED_SOS_PIN, 1);//Add pin led to drive
qled_set_special(QLED_SOS_PIN, sos_datas, sizeof(sos_datas)/sizeof(u16), qled_sos_cb);//Start performing a special sequence
}
Open the package and configure the parameters as needed by opening the package with the .Env configuration path: RT-Thread online packages -> peripherals packages -> quick led