Skip to content

Commit 0fa47c0

Browse files
committed
Cleanups
1 parent 496d898 commit 0fa47c0

27 files changed

+774
-771
lines changed

src/modm/driver/display/ili9341.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include <modm/platform/gpio/base.hpp>
2020
#include <modm/processing/resumable.hpp>
2121

22+
#include <modm/ui/color/rgb_stacked.hpp>
23+
#include <modm/ui/shape/point.hpp>
24+
#include <modm/ui/shape/line.hpp>
25+
#include <modm/ui/shape/section.hpp>
2226
#include <modm/ui/graphic/style.hpp>
2327

2428
#include <modm/ui/graphic/display.hpp>
@@ -38,7 +42,7 @@ namespace modm
3842
template<class Interface, class Reset, size_t BC = 512>
3943
// requires std::derived_from<Painter, RemotePainter<R>>
4044
class Ili9341 : public Interface,
41-
public Display<color::Rgb565, Resolution(320, 240), true>
45+
public Display<color::Rgb565, Size(320, 240), true>
4246
{
4347
// OPTIMIZE determine good contraints
4448
static_assert(BC >= 32, "Conversion Buffer < 64 pixels produces too much overhead.");
@@ -59,7 +63,7 @@ class Ili9341 : public Interface,
5963
template<typename... Args>
6064
Ili9341(Args &&...args)
6165
: Interface(std::forward<Args>(args)...),
62-
Display<Rgb565, Resolution(320, 240), true>(color::html::White)
66+
Display<Rgb565, Size(320, 240), true>(color::html::White)
6367
{ Reset::setOutput(modm::Gpio::High); }
6468

6569
~Ili9341(){};

src/modm/driver/display/ili9341_impl.hpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ modm::Ili9341<Interface, Reset, BC>::setOrientation(
154154
this->orientation = orientation;
155155

156156
using MemoryAccessCtrl = ili9341_register::MemoryAccessCtrl;
157-
using OrientationFlags = modm::graphic::OrientationFlags;
157+
using OrientationFlags = graphic::OrientationFlags;
158158

159159
madCtrl = MemoryAccessCtrl::PIXEL_DIR;
160160

@@ -268,33 +268,33 @@ template<class Interface, class Reset, size_t BC>
268268
template<Color C, template<typename> class Accessor>
269269
modm::ResumableResult<void>
270270
modm::Ili9341<Interface, Reset, BC>::writeImage(ImageAccessor<C, Accessor> accessor, Point origin) {
271-
// Found no cast for d share the memory between all of the writeImage()-methods.
271+
// Found no cast for a share the memory between all of the writeImage()-methods.
272272
// This waste of RAM will be history once Resumable Functions become history.
273-
static ImageAccessor<C, Accessor> d;
273+
static ImageAccessor<C, Accessor> a;
274274

275275
RF_BEGIN();
276276

277-
d = accessor;
277+
a = accessor;
278278

279-
this->clipping = this->getIntersection(Rectangle(origin, d.getSize()));
279+
this->clipping = this->getIntersection(Rectangle(origin, a.getSize()));
280280
RF_CALL(updateClipping());
281281

282282
// FIXME store image locally
283-
d.initialize(origin);
283+
a.initialize(origin);
284284
p.scanner = this->clipping.topLeft;
285285

286286
while (p.pixels)
287287
{
288288
// Fill buffer
289289
for(p.i = 0; p.i < std::min<uint32_t>(p.pixels, BC); p.i++) {
290290
if constexpr (ColorGrayBase2<C>)
291-
p.buffer[p.i] = colormap[d.nextPixel().getValue()];
291+
p.buffer[p.i] = colormap[a.nextPixel().getValue()];
292292
else
293-
p.buffer[p.i] = d.nextPixel();
293+
p.buffer[p.i] = a.nextPixel();
294294

295295
if (++p.scanner.y == this->clipping.bottomRight.y) {
296296
scannerincrementRow();
297-
d.incrementRow();
297+
a.incrementRow();
298298
}
299299
}
300300
// Transfer buffer
@@ -310,34 +310,34 @@ template<template<typename> class Accessor>
310310
modm::ResumableResult<void>
311311
modm::Ili9341<Interface, Reset, BC>::writeImage(ImageAccessor<ColorType, Accessor> accessor, Point origin)
312312
{
313-
// Found no cast for d share the memory between all of the writeImage()-methods.
313+
// Found no cast for a share the memory between all of the writeImage()-methods.
314314
// This waste of RAM will be history once Resumable Functions become history.
315-
static ImageAccessor<ColorType, Accessor> d;
315+
static ImageAccessor<ColorType, Accessor> a;
316316

317317
RF_BEGIN();
318318

319-
d = accessor;
319+
a = accessor;
320320

321-
this->clipping = this->getIntersection(Rectangle(origin, d.size));
321+
this->clipping = this->getIntersection(Rectangle(origin, a.getSize()));
322322
RF_CALL(updateClipping());
323323

324-
d.initialize(origin);
324+
a.initialize(origin);
325325

326326
// Check if display is exceeded vertically
327-
if (origin.y < 0 or origin.y + d.size.y >= this->getHeight())
327+
if (origin.y < 0 or origin.y + a.size.y >= this->getHeight())
328328
{
329329
// Continuous transfer not possible, send row by row
330330
p.pixels_bulk = this->clipping.getHeight();
331331

332332
while(p.pixels >= p.pixels_bulk) {
333-
RF_CALL(this->writeData(d.getPointer() + 1, p.pixels_bulk));
334-
d.incrementRow();
333+
RF_CALL(this->writeData(a.getPointer() + 1, p.pixels_bulk));
334+
a.incrementRow();
335335
p.pixels -= p.pixels_bulk;
336336
}
337337
} else
338338
{
339339
// Transfer buffer in one shot
340-
RF_CALL(this->writeData(d.getPointer() + 1, p.pixels));
340+
RF_CALL(this->writeData(a.getPointer() + 1, p.pixels));
341341
}
342342
RF_END();
343343
}

src/modm/driver/display/ssd1306.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ struct ssd1306 : public ssd1306_register
9494
*/
9595
template<class I2cMaster, uint16_t H = 64>
9696
class Ssd1306 : public ssd1306,
97-
public graphic::Display<Monochrome, Resolution(128, H), false>,
97+
public graphic::Display<Monochrome, Size(128, H), false>,
9898
public I2cDevice<I2cMaster, 3, ssd1306::Ssd1306_I2cWriteTransaction>
9999
{
100100
static_assert((H == 64) or (H == 32), "Display height must be either 32 or 64 pixel!");
101101
public:
102102
using ColorType = Monochrome;
103-
using Buffer = graphic::Buffer<ColorType, Resolution(128, H)>;
103+
using Buffer = graphic::Buffer<ColorType, Size(128, H)>;
104104

105105
Ssd1306(uint8_t address = 0x3C)
106-
: Display<Monochrome, Resolution(128, H), false>(true), I2cDevice<I2cMaster, 3, ssd1306::Ssd1306_I2cWriteTransaction>(address)
106+
: Display<Monochrome, Size(128, H), false>(true), I2cDevice<I2cMaster, 3, ssd1306::Ssd1306_I2cWriteTransaction>(address)
107107
{}
108108

109109
/// Pings the display

src/modm/driver/touch/touch2046.hpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
*/
1212
// ----------------------------------------------------------------------------
1313

14-
#ifndef MODM_TOUCH2046_HPP
15-
#define MODM_TOUCH2046_HPP
14+
#pragma once
15+
16+
#include <array>
17+
#include <tuple>
1618

1719
#include <modm/architecture/interface/spi_device.hpp>
1820
#include <modm/architecture/interface/gpio.hpp>
1921
#include <modm/processing/resumable.hpp>
20-
21-
#include <array>
22-
#include <tuple>
2322
#include <modm/ui/graphic/display.hpp>
24-
#include <modm/ui/shape/point.hpp>
23+
24+
using namespace modm::shape;
2525

2626
namespace modm
2727
{
@@ -120,7 +120,7 @@ struct touch2046 {
120120
*
121121
* Datasheet TSC2046: https://www.ti.com/lit/ds/symlink/tsc2046.pdf
122122
*/
123-
template < class SpiMaster, class Cs, Resolution R>
123+
template < class SpiMaster, class Cs, Size R>
124124
class Touch2046 : public touch2046, public modm::SpiDevice< SpiMaster >, protected modm::NestedResumable<3>
125125
{
126126
public:
@@ -197,9 +197,6 @@ class Touch2046 : public touch2046, public modm::SpiDevice< SpiMaster >, protect
197197

198198
Orientation orientation = Orientation::Portrait90;
199199
};
200+
} // namespace modm
200201

201-
} // modm namespace
202-
203-
#include "touch2046_impl.hpp"
204-
205-
#endif // MODM_TOUCH2046_HPP
202+
#include "touch2046_impl.hpp"

src/modm/driver/touch/touch2046_impl.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <modm/math/utils/endianness.hpp>
1818

19-
template<class SpiMaster, class Cs, Resolution R>
19+
template<class SpiMaster, class Cs, Size R>
2020
modm::ResumableResult<void>
2121
modm::Touch2046<SpiMaster, Cs, R>::updateZ()
2222
{
@@ -35,7 +35,7 @@ modm::Touch2046<SpiMaster, Cs, R>::updateZ()
3535
RF_END_RETURN();
3636
}
3737

38-
template<class SpiMaster, class Cs, Resolution R>
38+
template<class SpiMaster, class Cs, Size R>
3939
modm::ResumableResult<void>
4040
modm::Touch2046<SpiMaster, Cs, R>::updateXY()
4141
{
@@ -59,7 +59,7 @@ modm::Touch2046<SpiMaster, Cs, R>::updateXY()
5959
RF_END_RETURN();
6060
}
6161

62-
template<class SpiMaster, class Cs, Resolution R>
62+
template<class SpiMaster, class Cs, Size R>
6363
modm::ResumableResult<bool>
6464
modm::Touch2046<SpiMaster, Cs, R>::isTouched()
6565
{
@@ -68,7 +68,7 @@ modm::Touch2046<SpiMaster, Cs, R>::isTouched()
6868
RF_END_RETURN(z > cal.ThresholdZ);
6969
}
7070

71-
template<class SpiMaster, class Cs, Resolution R>
71+
template<class SpiMaster, class Cs, Size R>
7272
modm::ResumableResult<modm::shape::Point>
7373
modm::Touch2046<SpiMaster, Cs, R>::getTouchPoint()
7474
{
@@ -85,7 +85,7 @@ modm::Touch2046<SpiMaster, Cs, R>::getTouchPoint()
8585
RF_END();
8686
}
8787

88-
template<class SpiMaster, class Cs, Resolution R>
88+
template<class SpiMaster, class Cs, Size R>
8989
modm::ResumableResult<std::tuple<uint16_t, uint16_t>>
9090
modm::Touch2046<SpiMaster, Cs, R>::getTouchPosition()
9191
{

src/modm/ui/graphic/accessor_image.hpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
#include <modm/architecture/interface/accessor.hpp>
1717
#include <modm/math/utils/bit_constants.hpp>
1818

19-
#include <modm/ui/color.hpp>
19+
#include <modm/ui/color/concepts.hpp>
2020
#include <modm/ui/shape/point.hpp>
2121

22-
using namespace modm::color;
23-
2422
namespace modm::graphic
2523
{
2624
template<class C, template<typename> class>
@@ -32,13 +30,13 @@ class ImageAccessor;
3230
* @tparam C colormodel
3331
* @tparam Accessor Ram or Flash accessor
3432
*/
35-
template<Color C, template<typename> class Accessor>
33+
template<color::Color C, template<typename> class Accessor>
3634
class ImageAccessor<C, Accessor> : public Accessor<C>
3735
{
3836
public:
3937
ImageAccessor() = default;
4038

41-
ImageAccessor(const C* addr, modm::shape::Point size) : Accessor<C>(addr), size(size) {}
39+
ImageAccessor(const C* addr, shape::Size size) : Accessor<C>(addr), size(size) {}
4240

4341
ImageAccessor(const C* addr) : Accessor<C>(addr + 2) {
4442
auto flash = modm::accessor::asFlash(addr);
@@ -50,14 +48,14 @@ class ImageAccessor<C, Accessor> : public Accessor<C>
5048
{}
5149

5250
void
53-
initialize(const modm::shape::Point origin)
51+
initialize(const shape::Point origin)
5452
{
55-
const Point topLeft = {origin.x < 0 ? -origin.x : 0, origin.y < 0 ? -origin.y : 0};
53+
const shape::Point topLeft = {origin.x < 0 ? -origin.x : 0, origin.y < 0 ? -origin.y : 0};
5654
this->address += topLeft.x * size.y + topLeft.y - 1;
5755
addr_top = this->address;
5856
}
5957

60-
modm::shape::Point getSize() const {
58+
shape::Size getSize() const {
6159
return size;
6260
}
6361

@@ -76,7 +74,7 @@ class ImageAccessor<C, Accessor> : public Accessor<C>
7674
}
7775

7876
private:
79-
modm::shape::Point size;
77+
shape::Size size;
8078
const C* addr_top;
8179
};
8280

src/modm/ui/graphic/accessor_image_gray.hpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
#pragma once
1313
#include "accessor_image.hpp"
1414

15-
#include <modm/ui/color/gray.hpp>
16-
17-
using namespace modm::color;
15+
#include <modm/ui/color/concepts.hpp>
16+
#include <modm/ui/shape/point.hpp>
1817

1918
namespace modm::graphic
2019
{
@@ -23,35 +22,35 @@ namespace modm::graphic
2322
* @brief Image accessor for stackked grayscale image data
2423
*
2524
*/
26-
template<ColorGrayBase2 G, template<typename> class Accessor>
27-
class ImageAccessor<G, Accessor> : public Accessor<typename G::ValueType>
25+
template<color::ColorGrayBase2 C, template<typename> class Accessor>
26+
class ImageAccessor<C, Accessor> : public Accessor<typename C::ValueType>
2827
{
2928
public:
3029
ImageAccessor() = default;
3130

32-
ImageAccessor(const G::ValueType* addr, modm::shape::Point size) : Accessor<typename G::ValueType>(addr), size(size) {}
31+
ImageAccessor(const C::ValueType* addr, shape::Point size) : Accessor<typename C::ValueType>(addr), size(size) {}
3332

34-
ImageAccessor(const G::ValueType* addr) : Accessor<typename G::ValueType>(addr + 2)
33+
ImageAccessor(const C::ValueType* addr) : Accessor<typename C::ValueType>(addr + 2)
3534
{
3635
auto flash = modm::accessor::asFlash(addr);
3736
size = {flash[0], flash[1]};
3837
}
3938

40-
ImageAccessor(const BufferInterface<G>* buffer)
41-
: Accessor<typename G::ValueType>(buffer->getBuffer()), size(buffer->getSize())
39+
ImageAccessor(const BufferInterface<C>* buffer)
40+
: Accessor<typename C::ValueType>(buffer->getBuffer()), size(buffer->getSize())
4241
{}
4342

4443
inline void
45-
initialize(const modm::shape::Point origin)
44+
initialize(const shape::Point origin)
4645
{
47-
const Point topLeft = {origin.x < 0 ? -origin.x : 0, origin.y < 0 ? -origin.y : 0};
46+
const shape::Point topLeft = {origin.x < 0 ? -origin.x : 0, origin.y < 0 ? -origin.y : 0};
4847

49-
addr_top = this->address + (topLeft.y * G::Digits / 8) * size.x + topLeft.x;
50-
rotl_top = topLeft.y * G::Digits % 8;
48+
addr_top = this->address + (topLeft.y * C::Digits / 8) * size.x + topLeft.x;
49+
rotl_top = topLeft.y * C::Digits % 8;
5150
incrementRow();
5251
}
5352

54-
modm::shape::Point getSize() const {
53+
shape::Size getSize() const {
5554
return size;
5655
}
5756

@@ -64,33 +63,33 @@ class ImageAccessor<G, Accessor> : public Accessor<typename G::ValueType>
6463
// if (rotl_top == digits)
6564
// this->address -= size.x;
6665

67-
byte = std::rotr(Accessor<uint8_t>::operator*(), rotl_top - G::Digits);
66+
byte = std::rotr(Accessor<uint8_t>::operator*(), rotl_top - C::Digits);
6867
}
6968

70-
inline G
69+
inline C
7170
nextPixel()
7271
{
73-
rotl += G::Digits;
74-
if (rotl > numeric_limits<typename G::ValueType>::digits)
72+
rotl += C::Digits;
73+
if (rotl > numeric_limits<typename C::ValueType>::digits)
7574
{
7675
this->address += size.x;
7776
byte = Accessor<uint8_t>::operator*();
78-
rotl = G::Digits;
77+
rotl = C::Digits;
7978
} else {
80-
byte = std::rotr(byte, G::Digits);
79+
byte = std::rotr(byte, C::Digits);
8180
}
8281

83-
return byte & G::max;
82+
return byte & C::max;
8483
}
8584
private:
86-
modm::shape::Point size;
85+
shape::Size size;
8786

8887
// init state
89-
const G::ValueType* addr_top;
88+
const C::ValueType* addr_top;
9089
int8_t rotl_top;
9190

9291
// reader state
93-
G::ValueType byte;
92+
C::ValueType byte;
9493
int8_t rotl;
9594
};
9695
} // namespace modm::graphic

0 commit comments

Comments
 (0)