use ledring12.c file
Posted: Thu Nov 12, 2020 9:02 pm
I want to use the ws2812 led module.
I have already confirmed that the related functions are defined in the file called ledring12.
it is manipulated through Python files.
However, I would like to control the led by adding a new test without purchasing the ledring deck.
I'd like to know how to implement this.
What I've done now is as follows.
You tried to randomly select and execute one of the functions by adding the ledring12.h file to the new test.
The following is the code I used.
1.example.c
2.ledring12.h
Q1 : How do I use the ledring12.c file on a bolt other than Python without using the ledring deck?
Q2 : Do you have any code that implements simple led ON-OFF?
Q3 : If you have a different c/h code than ledring12.c/h, could you share it?
I have already confirmed that the related functions are defined in the file called ledring12.
it is manipulated through Python files.
However, I would like to control the led by adding a new test without purchasing the ledring deck.
I'd like to know how to implement this.
What I've done now is as follows.
You tried to randomly select and execute one of the functions by adding the ledring12.h file to the new test.
Code: Select all
---
SYS: Crazyflie Bolt is up and running!
SYS: Build 73:a373c467177b (2020.09 +73) MODIFIED
SYS: I am 0x20373347344D500E0027003C and I have 1024KB of flash!
CFGBLK: v1, verification [OK]
Example task main function is running!DECK_CORE: 0 deck(s) found
IMU: BMI088 Gyro SPI connection [OK].
IMU: BMI088 Accel SPI connection [OK]
IMU: BMP388 I2C connection [OK]
ESTIMATOR: Using Complementary (1) estimator
CONTROLLER: Using PID (1) controller
MTR-DRV: Using brushless motor driver
EEPROM: I2C connection [OK].
STORAGE: Storage check [OK].
IMU: BMI088 gyro self-test [OK]
SYS: The system resumed after watchdog timeout [WARNING]
1.example.c
Code: Select all
#include "config.h"
#include "debug.h"
#include "FreeRTOS.h"
#include "queue.h"
#include "static_mem.h"
#include "task.h"
#include "ledring12.h"
static xQueueHandle inputQueue;
STATIC_MEM_QUEUE_ALLOC(inputQueue, 1, sizeof(int));
static void exampleTask(void*);
STATIC_MEM_TASK_ALLOC(exampleTask, EXAMPLE_TASK_STACKSIZE);
static bool isInit = false;
#define white_led {0xff, 0xff, 0xff}
uint8_t led_buffer[][3] = {white_led,white_led,white_led,
white_led,white_led,white_led,
white_led,white_led,white_led,
white_led,white_led,white_led};
//1st parameter
static bool led_test = true; //2nd parameter
void exampleTaskInit() {
inputQueue = STATIC_MEM_QUEUE_CREATE(inputQueue);
// TODO
STATIC_MEM_TASK_CREATE(exampleTask, exampleTask, EXAMPLE_TASK_NAME, NULL, EXAMPLE_TASK_PRI);
isInit = true;
}
bool exampleTaskTest() {
return isInit;
}
void exampleTaskEnqueueInput(int value) {
xQueueOverwrite(inputQueue, &value);
}
static void exampleTask(void* parameters) {
DEBUG_PRINT("Example task main function is running!");
while (true) {
int input;
exampleTaskEnqueueInput(input);
if (pdTRUE == xQueueReceive(inputQueue, &input, portMAX_DELAY)) {
whiteSpinEffect(led_buffer, led_test);
// Respond to input here!
}
}
}
Code: Select all
#ifndef __LEDRING12_H__
#define __LEDRING12_H__
#include <stdint.h>
#include <stdbool.h>
#ifdef LED_RING_NBR_LEDS
#define NBR_LEDS LED_RING_NBR_LEDS
#else
#define NBR_LEDS 12
#endif
#ifndef LEDRING_TIME_MEM_SIZE
#define LEDRING_TIME_MEM_SIZE 10
#endif
extern uint8_t ledringmem[NBR_LEDS * 2];
typedef struct __attribute__((packed)) timing
{
uint8_t duration; // How long this color should be show in parts of 1/25s. So 25 will show the color 1s, before going to the next color.
uint8_t color[2]; // What color should be shown in RGB565 format.
unsigned leds:4; // What led should be show, 0 equals all leds.
bool fade:1; // Fade from previous colour to this colour during the full duration.
unsigned rotate:3; // Speed of the rotation, number of seconds per revolution
} ledtiming;
typedef struct timings
{
uint32_t hash; // Hash will later be used to check if the contents is already uploaded, so we don't reupload
ledtiming timings[LEDRING_TIME_MEM_SIZE];
} ledtimings;
extern ledtimings ledringtimingsmem;
void whiteSpinEffect(uint8_t buffer[][3], bool reset);
#endif //__LEDRING12_H__
Q1 : How do I use the ledring12.c file on a bolt other than Python without using the ledring deck?
Q2 : Do you have any code that implements simple led ON-OFF?
Q3 : If you have a different c/h code than ledring12.c/h, could you share it?