A simple operating system for the ESP32-based M5StickC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.5 KiB

4 years ago
#include <M5StickC.h>
#include "Kernel.h"
#include "EAT.h"
4 years ago
#include "Colours.h"
#include "PowerManagement.h"
#include "UserInput.h"
#include "Clock.h"
4 years ago
int count = 0;
int test_func(int pid, unsigned int signal)
{
4 years ago
if (signal & SIGNAL_START)
{
Kernel_signal_mask(pid, SIGNAL_START | SIGNAL_STOP | SIGNAL_TICK | SIGNAL_REDRAW);
if (EAT_allocate(1, 2))
{
EAT_write(1, 0, 0);
EAT_write(1, 1, 0);
}
else
{
byte count_low = EAT_read(1, 0);
byte count_hi = EAT_read(1, 1);
count = (count_hi << 8) + count_low;
}
4 years ago
}
if ((signal & SIGNAL_STOP)) // || count == 5)
4 years ago
{
EAT_write(1, 0, count & 0xFF);
EAT_write(1, 1, (count >> 8) & 0xFF);
4 years ago
return 255;
}
if ((signal & SIGNAL_TICK) && (signal & SIGNAL_INPUT_A) == 0 && (signal & SIGNAL_INPUT_B) == 0)
4 years ago
{
count++;
Kernel_signal(SIGNAL_REDRAW);
4 years ago
}
if (signal & SIGNAL_REDRAW)
{
M5.Lcd.setCursor(0, 0);
M5.Lcd.print("Ran: ");
M5.Lcd.print(String(count));
M5.Lcd.print(" times");
}
4 years ago
return 0;
}
void setup()
{
M5.begin();
Kernel_setup();
Kernel_start(&PowerManagement, 1000);
Kernel_start(&UserInput, 0);
//Kernel_start(&test_func, 5000);
Kernel_start(&Clock, 1000);
M5.update();
if (M5.BtnB.isPressed())
{
EAT_initialize();
}
else
{
EAT_load();
}
M5.Lcd.fillScreen(TFT_DARKGREY);
M5.Lcd.setRotation(3);
M5.Lcd.setTextColor(TFT_WHITE, TFT_DARKGREY);
4 years ago
}
void loop()
{
M5.update();
4 years ago
Kernel_tick();
}