mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-21 12:01:47 +02:00
experimenting with xTaskCreate
This commit is contained in:
parent
f2253a7cb5
commit
e42058bb82
@ -26,57 +26,5 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
#define GPIO_LED 48
|
||||
|
||||
void Dezibot::begin(void) {
|
||||
Adafruit_NeoPixel ledStrip = Adafruit_NeoPixel(3, GPIO_LED, NEO_GRB + NEO_KHZ800);
|
||||
Wire.begin(1, 2);
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println("SSD1306 allocation failed");
|
||||
for (;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
display.display();
|
||||
vTaskDelay(2000);
|
||||
display.clearDisplay();
|
||||
vTaskDelay(2000);
|
||||
|
||||
// Draw a single pixel in white
|
||||
display.drawPixel(10, 10, SSD1306_WHITE);
|
||||
|
||||
// Show the display buffer on the screen. You MUST call display() after
|
||||
// drawing commands to make them visible on screen!
|
||||
display.display();
|
||||
vTaskDelay(2000);
|
||||
|
||||
Serial.begin(9600);
|
||||
Serial.println("start");
|
||||
|
||||
|
||||
vTaskDelay(1000);
|
||||
|
||||
while (1) {
|
||||
/* Blink off (output low) */
|
||||
ledStrip.setPixelColor(1, ledStrip.Color(100, 100, 100));
|
||||
ledStrip.show(); // Aktualisiere die Farbe des Pixels
|
||||
vTaskDelay(1000);
|
||||
/* Blink on (output high) */
|
||||
ledStrip.setPixelColor(1, ledStrip.Color(0, 0, 0));
|
||||
ledStrip.show(); // Aktualisiere die Farbe des Pixels
|
||||
vTaskDelay(1000);
|
||||
|
||||
struct timeval tv_now;
|
||||
gettimeofday(&tv_now, NULL);
|
||||
int64_t time_us = (int64_t) tv_now.tv_sec * 1000000L + (int64_t) tv_now.tv_usec;
|
||||
|
||||
|
||||
Serial.println(time_us);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.setCursor(10, 0);
|
||||
display.println(F("scroll"));
|
||||
display.display(); // Show initial text
|
||||
vTaskDelay(1000);
|
||||
|
||||
}
|
||||
motion.begin();
|
||||
}
|
@ -20,16 +20,20 @@ Motion::Motion() {
|
||||
void Motion::begin(void) {
|
||||
|
||||
}
|
||||
|
||||
// Move forward for a certain amount of time.
|
||||
void Motion::move(uint32_t moveForMs) {
|
||||
void moveTask(void * moveForMs) {
|
||||
analogWrite(MOTOR_LEFT_PIN, 128);
|
||||
analogWrite(MOTOR_RIGHT_PIN, 128);
|
||||
vTaskDelay(moveForMs);
|
||||
vTaskDelay((uint32_t) moveForMs);
|
||||
analogWrite(MOTOR_LEFT_PIN, 0);
|
||||
analogWrite(MOTOR_RIGHT_PIN, 0);
|
||||
}
|
||||
|
||||
// Move forward for a certain amount of time.
|
||||
void Motion::move(uint32_t moveForMs) {
|
||||
xTaskCreate(moveTask, "Move", configMINIMAL_STACK_SIZE, (void*)moveForMs, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
// Rotate clockwise for a certain amount of time.
|
||||
void Motion::rotateClockwise(uint32_t rotateForMs) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user