Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[graphic] Rewrite graphics - Round 1 #665

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions examples/nucleo_l452re/graphics_touch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace touch
//using Interrupt = modm::platform::GpioA10;
}

modm::Touch2046<touch::Spi, touch::Cs> touchController;
modm::Touch2046<touch::Spi, touch::Cs, 320, 240> touchController;


int
Expand All @@ -75,12 +75,10 @@ main()
touch::Mosi::Mosi>();
touch::Spi::initialize<SystemClock, 2500_kHz>();
modm::touch2046::Calibration cal{
.OffsetX = -11,
.OffsetY = 335,
.FactorX = 22018,
.OffsetX = -11,
.FactorY = -29358,
.MaxX = 240,
.MaxY = 320,
.OffsetY = 335,
.ThresholdZ = 500,
};
touchController.setCalibration(cal);
Expand All @@ -107,22 +105,22 @@ main()

int16_t X = 0;
int16_t Y = 0;
int16_t Z = 0;
// int16_t Z = 0;

while (true)
{
LedGreen::set();

std::tie(X, Y, Z) = RF_CALL_BLOCKING(touchController.getRawValues());
std::tie(X, Y) = RF_CALL_BLOCKING(touchController.getTouchPosition());
tftController.setColor(Red);
tftController.fillRectangle({30, 50}, 90, 115);
tftController.setColor(Black);
tftController.setCursor(0, 50);
tftController << "X=" << X;
tftController.setCursor(0, 90);
tftController << "Y=" << Y;
tftController.setCursor(0, 130);
tftController << "Z=" << Z;
// tftController.setCursor(0, 130);
// tftController << "Z=" << Z;

tftController.setColor(Red);
tftController.fillRectangle({30, 220}, 120, 35);
Expand Down
2 changes: 1 addition & 1 deletion examples/nucleo_l452re/lvgl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace touch
//using Interrupt = modm::platform::GpioA10;
}

modm::Touch2046<touch::Spi, touch::Cs> touchController;
modm::Touch2046<touch::Spi, touch::Cs, 320, 240> touchController;


static lv_disp_draw_buf_t disp_buf;
Expand Down
2 changes: 1 addition & 1 deletion src/modm/architecture/interface/accessor_flash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Flash
return address;
}

private:
protected:
const T* address;
#if MODM_HAS_IOSTREAM
private:
Expand Down
2 changes: 1 addition & 1 deletion src/modm/architecture/interface/accessor_ram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Ram
return address;
}

private:
protected:
const T* address;
};

Expand Down
53 changes: 45 additions & 8 deletions src/modm/architecture/interface/spi_master.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (c) 2010, Martin Rosekeit
* Copyright (c) 2012-2017, Niklas Hauser
* Copyright (c) 2013, Sascha Schade
* Copyright (c) 2021, Thomas Sommer
*
* This file is part of the modm project.
*
Expand Down Expand Up @@ -96,14 +97,28 @@ class SpiMaster : public ::modm::PeripheralDriver, public Spi
release(void *ctx);

/**
* Swap a single byte and wait for completion.
* Swap a single byte or word or word and wait for completion.
*
* @param data
* data to be sent
* @return received data
*/
static uint8_t
transferBlocking(uint8_t data);
template <std::unsigned_integral T>
static T
transferBlocking(T data);

/**
* Swap a single byte or word or word multiple times and wait for completion non-blocking!
* This may be hardware accelerated (DMA or Interrupt), but not guaranteed.
*
* @param[in] tx
* pointer to transmit data
* @param repeat
* number of repetitions for same byte or word or word
*/
template <std::unsigned_integral T>
static modm::ResumableResult<void>
transfer(const T *tx, const std::size_t repeat);

/**
* Set the data buffers and length with options and starts a transfer.
Expand All @@ -116,11 +131,12 @@ class SpiMaster : public ::modm::PeripheralDriver, public Spi
* @param length
* number of bytes to be shifted out
*/
template <std::unsigned_integral T>
static void
transferBlocking(const uint8_t *tx, uint8_t *rx, std::size_t length);
transferBlocking(const T *tx, T *rx, const std::size_t length);

/**
* Swap a single byte and wait for completion non-blocking!.
* Swap a single byte or word and wait for completion non-blocking!
*
* You must call this inside a Protothread or Resumable
* using `PT_CALL` or `RF_CALL` respectively.
Expand All @@ -132,8 +148,28 @@ class SpiMaster : public ::modm::PeripheralDriver, public Spi
* data to be sent
* @return received data
*/
static modm::ResumableResult<uint8_t>
transfer(uint8_t data);
template <std::unsigned_integral T>
static modm::ResumableResult<T>
transfer(T data);

/**
* Swap a single byte or word multiple times and wait for completion non-blocking!
* This may be hardware accelerated (DMA or Interrupt), but not guaranteed.
*
* You must call this inside a Protothread or Resumable
* using `PT_CALL` or `RF_CALL` respectively.
* @warning These methods differ from Resumables by lacking context protection!
* You must ensure that only one driver is accessing this resumable function
* by using `acquire(ctx)` and `release(ctx)`.
*
* @param[in] tx
* pointer to transmit data
* @param repeat
* number of repetitions for same byte or word
*/
template <std::unsigned_integral T>
static modm::ResumableResult<void>
transfer(const T *tx, const std::size_t repeat);

/**
* Set the data buffers and length with options and
Expand All @@ -153,8 +189,9 @@ class SpiMaster : public ::modm::PeripheralDriver, public Spi
* @param length
* number of bytes to be shifted out
*/
template <std::unsigned_integral T>
static modm::ResumableResult<void>
transfer(const uint8_t *tx, uint8_t *rx, std::size_t length);
transfer(const T *tx, T *rx, const std::size_t length);
#endif
};

Expand Down
Loading