refactor tree, add ecad, mcad
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Bsp/Drivers/DisplayDriver.h"
|
||||
#include "Bsp/macros.h"
|
||||
@@ -27,10 +28,10 @@
|
||||
|
||||
namespace BSP {
|
||||
|
||||
using Common::Schedule::NextTime;
|
||||
using Common::ReturnCode;
|
||||
using BSP::Schedule::NextTime;
|
||||
using BSP::ReturnCode;
|
||||
|
||||
DisplayDriver::DisplayDriver(Common::Schedule::TaskScheduler &scheduler, SpiDriver &spi)
|
||||
DisplayDriver::DisplayDriver(BSP::Schedule::TaskScheduler &scheduler, SpiDriver &spi)
|
||||
: m_scheduler(scheduler)
|
||||
, m_spi(spi)
|
||||
, m_is_dirty(true)
|
||||
@@ -42,7 +43,7 @@ DisplayDriver::DisplayDriver(Common::Schedule::TaskScheduler &scheduler, SpiDriv
|
||||
|
||||
ReturnCode DisplayDriver::init()
|
||||
{
|
||||
return Common::ReturnCode::OK;
|
||||
return BSP::ReturnCode::OK;
|
||||
}
|
||||
|
||||
NextTime DisplayDriver::execute()
|
||||
@@ -98,6 +99,45 @@ void DisplayDriver::set_dirty(unsigned int y)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DisplayDriver::draw_line(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, Color color, int32_t width)
|
||||
{
|
||||
const int32_t dx = abs(x1 - x0);
|
||||
const int32_t sx = (x0 < x1) ? 1 : -1;
|
||||
const int32_t dy = -abs(y1 - y0);
|
||||
const int32_t sy = (y0 < y1) ? 1 : -1;
|
||||
int32_t err = dx + dy;
|
||||
|
||||
uint32_t x = x0;
|
||||
uint32_t y = y0;
|
||||
|
||||
while (true) {
|
||||
for (int32_t i = -width / 2; i < (-width / 2) + width; i++) {
|
||||
uint32_t xp, yp;
|
||||
if (dx > -dy) {
|
||||
xp = x;
|
||||
yp = y + i;
|
||||
} else {
|
||||
xp = x + i;
|
||||
yp = y;
|
||||
}
|
||||
set_pixel(xp, yp, color);
|
||||
}
|
||||
if (x == x1 && y == y1)
|
||||
break;
|
||||
|
||||
const int32_t e2 = 2 * err;
|
||||
if (e2 >= dy) {
|
||||
err += dy;
|
||||
x += sx;
|
||||
}
|
||||
if (e2 <= dx) {
|
||||
err += dx;
|
||||
y += sy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: write my own implementation
|
||||
#define R2(n) n, n + 2*64, n + 1*64, n + 3*64
|
||||
#define R4(n) R2(n), R2(n + 2*16), R2(n + 1*16), R2(n + 3*16)
|
||||
|
||||
Reference in New Issue
Block a user