Skip to content

Commit 7758b7a

Browse files
committed
rewrite graphics
1 parent 79eb43b commit 7758b7a

File tree

178 files changed

+7712
-15246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+7712
-15246
lines changed

Diff for: examples/nucleo_l452re/graphics_touch/main.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace touch
5151
//using Interrupt = modm::platform::GpioA10;
5252
}
5353

54-
modm::Touch2046<touch::Spi, touch::Cs> touchController;
54+
modm::Touch2046<touch::Spi, touch::Cs, 320, 240> touchController;
5555

5656

5757
int
@@ -75,12 +75,10 @@ main()
7575
touch::Mosi::Mosi>();
7676
touch::Spi::initialize<SystemClock, 2500_kHz>();
7777
modm::touch2046::Calibration cal{
78-
.OffsetX = -11,
79-
.OffsetY = 335,
8078
.FactorX = 22018,
79+
.OffsetX = -11,
8180
.FactorY = -29358,
82-
.MaxX = 240,
83-
.MaxY = 320,
81+
.OffsetY = 335,
8482
.ThresholdZ = 500,
8583
};
8684
touchController.setCalibration(cal);
@@ -107,22 +105,22 @@ main()
107105

108106
int16_t X = 0;
109107
int16_t Y = 0;
110-
int16_t Z = 0;
108+
// int16_t Z = 0;
111109

112110
while (true)
113111
{
114112
LedGreen::set();
115113

116-
std::tie(X, Y, Z) = RF_CALL_BLOCKING(touchController.getRawValues());
114+
std::tie(X, Y) = RF_CALL_BLOCKING(touchController.getTouchPosition());
117115
tftController.setColor(Red);
118116
tftController.fillRectangle({30, 50}, 90, 115);
119117
tftController.setColor(Black);
120118
tftController.setCursor(0, 50);
121119
tftController << "X=" << X;
122120
tftController.setCursor(0, 90);
123121
tftController << "Y=" << Y;
124-
tftController.setCursor(0, 130);
125-
tftController << "Z=" << Z;
122+
// tftController.setCursor(0, 130);
123+
// tftController << "Z=" << Z;
126124

127125
tftController.setColor(Red);
128126
tftController.fillRectangle({30, 220}, 120, 35);

Diff for: examples/nucleo_l452re/lvgl/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace touch
5959
//using Interrupt = modm::platform::GpioA10;
6060
}
6161

62-
modm::Touch2046<touch::Spi, touch::Cs> touchController;
62+
modm::Touch2046<touch::Spi, touch::Cs, 320, 240> touchController;
6363

6464

6565
static lv_disp_draw_buf_t disp_buf;

Diff for: src/modm/architecture/interface/accessor_flash.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class Flash
162162
return address;
163163
}
164164

165-
private:
165+
protected:
166166
const T* address;
167167
#if MODM_HAS_IOSTREAM
168168
private:

Diff for: src/modm/architecture/interface/accessor_ram.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class Ram
117117
return address;
118118
}
119119

120-
private:
120+
protected:
121121
const T* address;
122122
};
123123

Diff for: src/modm/architecture/interface/spi_master.hpp

+45-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2010, Martin Rosekeit
44
* Copyright (c) 2012-2017, Niklas Hauser
55
* Copyright (c) 2013, Sascha Schade
6+
* Copyright (c) 2021, Thomas Sommer
67
*
78
* This file is part of the modm project.
89
*
@@ -96,14 +97,28 @@ class SpiMaster : public ::modm::PeripheralDriver, public Spi
9697
release(void *ctx);
9798

9899
/**
99-
* Swap a single byte and wait for completion.
100+
* Swap a single byte or word or word and wait for completion.
100101
*
101102
* @param data
102103
* data to be sent
103104
* @return received data
104105
*/
105-
static uint8_t
106-
transferBlocking(uint8_t data);
106+
template <std::unsigned_integral T>
107+
static T
108+
transferBlocking(T data);
109+
110+
/**
111+
* Swap a single byte or word or word multiple times and wait for completion non-blocking!
112+
* This may be hardware accelerated (DMA or Interrupt), but not guaranteed.
113+
*
114+
* @param[in] tx
115+
* pointer to transmit data
116+
* @param repeat
117+
* number of repetitions for same byte or word or word
118+
*/
119+
template <std::unsigned_integral T>
120+
static modm::ResumableResult<void>
121+
transfer(const T *tx, const std::size_t repeat);
107122

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

122138
/**
123-
* Swap a single byte and wait for completion non-blocking!.
139+
* Swap a single byte or word and wait for completion non-blocking!
124140
*
125141
* You must call this inside a Protothread or Resumable
126142
* using `PT_CALL` or `RF_CALL` respectively.
@@ -132,8 +148,28 @@ class SpiMaster : public ::modm::PeripheralDriver, public Spi
132148
* data to be sent
133149
* @return received data
134150
*/
135-
static modm::ResumableResult<uint8_t>
136-
transfer(uint8_t data);
151+
template <std::unsigned_integral T>
152+
static modm::ResumableResult<T>
153+
transfer(T data);
154+
155+
/**
156+
* Swap a single byte or word multiple times and wait for completion non-blocking!
157+
* This may be hardware accelerated (DMA or Interrupt), but not guaranteed.
158+
*
159+
* You must call this inside a Protothread or Resumable
160+
* using `PT_CALL` or `RF_CALL` respectively.
161+
* @warning These methods differ from Resumables by lacking context protection!
162+
* You must ensure that only one driver is accessing this resumable function
163+
* by using `acquire(ctx)` and `release(ctx)`.
164+
*
165+
* @param[in] tx
166+
* pointer to transmit data
167+
* @param repeat
168+
* number of repetitions for same byte or word
169+
*/
170+
template <std::unsigned_integral T>
171+
static modm::ResumableResult<void>
172+
transfer(const T *tx, const std::size_t repeat);
137173

138174
/**
139175
* Set the data buffers and length with options and
@@ -153,8 +189,9 @@ class SpiMaster : public ::modm::PeripheralDriver, public Spi
153189
* @param length
154190
* number of bytes to be shifted out
155191
*/
192+
template <std::unsigned_integral T>
156193
static modm::ResumableResult<void>
157-
transfer(const uint8_t *tx, uint8_t *rx, std::size_t length);
194+
transfer(const T *tx, T *rx, const std::size_t length);
158195
#endif
159196
};
160197

0 commit comments

Comments
 (0)