diff --git a/README.md b/README.md
index c2720896ea..32c7f8cc58 100644
--- a/README.md
+++ b/README.md
@@ -720,109 +720,108 @@ your specific needs.
ADS7843 |
ADS816x |
AMS5915 |
-ANGLE |
APA102 |
AS5047 |
-
AS5600 |
+
AT24MAC402 |
SPI Flash |
BME280 |
BMI088 |
BMP085 |
-
BNO055 |
+
CAT24AA |
CYCLE-COUNTER |
DRV832X |
DS1302 |
DS1631 |
-
DS18B20 |
+
EA-DOG |
Encoder Input |
Encoder Input BitBang |
Encoder Output BitBang |
FT245 |
-
FT6x06 |
+
Gpio Sampler |
HCLAx |
HD44780 |
HMC58x |
HMC6343 |
-
HX711 |
+
I2C-EEPROM |
ILI9341 |
IS31FL3733 |
ITG3200 |
IXM42XXX |
-
L3GD20 |
+
LAN8720A |
LAWICEL |
LIS302DL |
LIS3DSH |
LIS3MDL |
-
LM75 |
+
LP503x |
LSM303A |
LSM6DS33 |
LSM6DSO |
LTC2984 |
-
MAX31855 |
+
MAX31865 |
MAX6966 |
MAX7219 |
MCP23x17 |
MCP2515 |
-
MCP3008 |
+
MCP7941x |
MCP990X |
MMC5603 |
MS5611 |
MS5837 |
-
NOKIA5110 |
+
NRF24 |
TFT-DISPLAY |
PAT9125EL |
PCA8574 |
PCA9535 |
-
PCA9548A |
+
PCA9685 |
QMC5883L |
SH1106 |
SIEMENS-S65 |
SIEMENS-S75 |
-
SK6812 |
+
SK9822 |
SSD1306 |
ST7586S |
ST7789 |
STTS22H |
-
STUSB4500 |
+
SX1276 |
SX128X |
TCS3414 |
TCS3472 |
TLC594x |
-
TMP102 |
+
TMP12x |
TMP175 |
TOUCH2046 |
VL53L0 |
VL6180 |
-
WS2812 |
+
diff --git a/src/modm/driver/encoder/angle.hpp b/src/modm/driver/encoder/angle.hpp
deleted file mode 100644
index 28a88d58cc..0000000000
--- a/src/modm/driver/encoder/angle.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// coding: utf-8
-// ----------------------------------------------------------------------------
-/*
- * Copyright (c) 2024, Thomas Sommer
- *
- * This file is part of the modm project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-// ----------------------------------------------------------------------------
-
-#pragma once
-
-#include
-#include
-#include
-
-namespace modm {
-
- /// @brief Represents an absolute angle in a full circle
- template
- struct modm_packed Angle
- {
- using T = modm::least_uint;
- // @todo need something like modm::least_int;
- using DeltaType = int16_t;
-
- T data;
- static constexpr T max = std::pow(2, Bits) - 1;
-
- constexpr DeltaType
- getDelta() {
- static DeltaType previous{static_cast(data)};
- DeltaType delta = DeltaType(data) - previous;
-
- if(delta < -(max / 2)) {
- delta += max;
- } else if(delta > (max / 2)) {
- delta -= max;
- }
-
- previous = data;
-
- return delta;
- }
-
- /// @return
- constexpr float
- toDegree() const
- {
- return float(data) * 360 / max;
- }
-
- /// @return
- constexpr float
- toRadian() const
- {
- return float(data) * 2 * std::numbers::pi_v / max;
- }
- };
-}
\ No newline at end of file
diff --git a/src/modm/driver/encoder/angle.lb b/src/modm/driver/encoder/angle.lb
deleted file mode 100644
index 20d56e2d46..0000000000
--- a/src/modm/driver/encoder/angle.lb
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2024, Thomas Sommer
-#
-# This file is part of the modm project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-# -----------------------------------------------------------------------------
-
-def init(module):
- module.name = ":driver:angle"
- module.description = """\
-# Angle type for Encoder drivers
-"""
-
-def prepare(module, options):
- return True
-
-def build(env):
- env.outbasepath = "modm/src/modm/driver/encoder"
- env.copy("angle.hpp")
diff --git a/src/modm/driver/encoder/as5047.hpp b/src/modm/driver/encoder/as5047.hpp
index a9c15ebcfe..bb302ccc68 100644
--- a/src/modm/driver/encoder/as5047.hpp
+++ b/src/modm/driver/encoder/as5047.hpp
@@ -14,13 +14,12 @@
#pragma once
#include
+#include
#include
#include
#include
#include
-#include
-
-#include "angle.hpp"
+#include
namespace modm
{
@@ -82,7 +81,7 @@ struct as5047
};
- using Data = modm::Angle<14>;
+ using Data = modm::IntegerAngle<14>;
}; // struct as5047
/**
diff --git a/src/modm/driver/encoder/as5047.lb b/src/modm/driver/encoder/as5047.lb
index 71c14006dc..b9a4cbe19b 100644
--- a/src/modm/driver/encoder/as5047.lb
+++ b/src/modm/driver/encoder/as5047.lb
@@ -23,7 +23,7 @@ def prepare(module, options):
":architecture:gpio",
":architecture:spi.device",
":processing:resumable",
- ":driver:angle"
+ ":math:geometry"
)
return True
diff --git a/src/modm/driver/encoder/as5600.hpp b/src/modm/driver/encoder/as5600.hpp
index 73e3953cf5..f25475d20e 100644
--- a/src/modm/driver/encoder/as5600.hpp
+++ b/src/modm/driver/encoder/as5600.hpp
@@ -1,3 +1,4 @@
+
// coding: utf-8
// ----------------------------------------------------------------------------
/*
@@ -15,8 +16,7 @@
#include
#include
-
-#include "angle.hpp"
+#include
namespace modm
{
@@ -98,10 +98,10 @@ struct as5600
enum class PWMFrequency : uint16_t
{
- _115Hz = 0,
- _230_Hz = 1,
- _460_Hz = 2,
- _920_Hz = 3
+ Hz115 = 0,
+ Hz230 = 1,
+ Hz460 = 2,
+ Hz920 = 3
};
using PWMFrequency_t = Configuration;
@@ -116,20 +116,20 @@ struct as5600
enum class FastFilterThreshold : uint16_t
{
- _6LSB = 0,
- _7LSB = 1,
- _9LSB = 2,
- _18LSB = 3,
- _21LSB = 4,
- _24LSB = 5,
- _10LSB = 6
+ LSB6 = 0,
+ LSB7 = 1,
+ LSB9 = 2,
+ LSB18 = 3,
+ LSB21 = 4,
+ LSB24 = 5,
+ LSB10 = 6
};
using FastFilterThreshold_t = Configuration;
enum class Burn : uint8_t
{
- ANGLE = Bit3, // Burn Angle data. CAN ONLY BE DONE ONCE!
- CONFIG = Bit2 // Burn Config data. CAN ONLY BE DONE ONCE!
+ ANGLE = Bit3, // Burn Angle data
+ CONFIG = Bit2 // Burn Config data
};
// @see datasheet page 21
@@ -141,18 +141,19 @@ struct as5600
};
MODM_FLAGS8(Status);
- using Data = modm::Angle<12>;
+ using Data = modm::IntegerAngle<12>;
};
template
class As5600 : public as5600, public modm::I2cDevice
{
public:
- // AS5600 has hardwired address 0x36
- // AS4500L has default address 0x40 but supports programming a different one
+ /** AS5600 has hardwired address 0x36
+ * AS4500L has default address 0x40 but supports programming a different one
+ */
As5600(Data &data, uint8_t address = 0x36) : I2cDevice(address), data(data) {}
- /* Reset to Power up state.
+ /** Reset to Power up state.
* Useful for developement, not required in production.
*/
modm::ResumableResult
@@ -162,7 +163,7 @@ class As5600 : public as5600, public modm::I2cDevice
bool success = true;
- // Config spans from 0x00 to 0x08
+ // The config registers span from 0x00 to 0x08
for (uint8_t reg = 0x00; reg < 0x08; reg += 2)
{
buffer[0] = reg;
@@ -182,14 +183,14 @@ class As5600 : public as5600, public modm::I2cDevice
configure(Config_t config)
{
RF_BEGIN();
- RF_END_RETURN_CALL(write(Register::CONF, config.value));
+ return write(Register::CONF, config.value);
}
modm::ResumableResult
setI2cAddress(uint8_t address)
{
RF_BEGIN();
- RF_END_RETURN_CALL(write(Register::I2C_ADDR, address));
+ return write(Register::I2C_ADDR, address);
}
/*
@@ -199,7 +200,7 @@ class As5600 : public as5600, public modm::I2cDevice
setLowerLimit(Data data)
{
RF_BEGIN();
- RF_END_RETURN_CALL(write(Register::ZPOS, data.data));
+ return write(Register::ZPOS, data.data);
}
/*
@@ -209,14 +210,14 @@ class As5600 : public as5600, public modm::I2cDevice
setUpperLimit(Data data)
{
RF_BEGIN();
- RF_END_RETURN_CALL(write(Register::MPOS, data.data));
+ return write(Register::MPOS, data.data);
}
modm::ResumableResult
setMaxAngle(Data data)
{
RF_BEGIN();
- RF_END_RETURN_CALL(write(Register::MANG, data.data));
+ return write(Register::MANG, data.data);
}
/*
@@ -228,9 +229,9 @@ class As5600 : public as5600, public modm::I2cDevice
{
RF_BEGIN();
- buffer[0] = flags;
+ buffer[0] = static_cast(flags);
- RF_END_RETURN_CALL(write(Register::BURN, buffer, 1));
+ return write(Register::BURN, buffer, 1);
}
modm::ResumableResult
@@ -248,14 +249,14 @@ class As5600 : public as5600, public modm::I2cDevice
getStatus()
{
RF_BEGIN();
- RF_END_RETURN_CALL(Status(read(Register::STATUS)));
+ return static_cast(read(Register::STATUS));
}
modm::ResumableResult
getMagnitude()
{
RF_BEGIN();
- RF_END_RETURN_CALL(read(Register::MAGNITUDE));
+ return read(Register::MAGNITUDE);
}
/** Automated Gain Control
@@ -274,7 +275,7 @@ class As5600 : public as5600, public modm::I2cDevice
getAgcValue()
{
RF_BEGIN();
- RF_END_RETURN_CALL(read(Register::AGC));
+ return read(Register::AGC);
}
modm::ResumableResult
@@ -313,7 +314,7 @@ class As5600 : public as5600, public modm::I2cDevice
this->transaction.configureWrite(buffer, 1 + sizeof(T));
- RF_END_RETURN_CALL(this->runTransaction());
+ return this->runTransaction();
}
template
diff --git a/src/modm/driver/encoder/as5600.lb b/src/modm/driver/encoder/as5600.lb
index ad80b92266..5cf328aecc 100644
--- a/src/modm/driver/encoder/as5600.lb
+++ b/src/modm/driver/encoder/as5600.lb
@@ -23,7 +23,7 @@ def prepare(module, options):
":architecture:gpio",
":architecture:i2c.device",
":processing:resumable",
- ":driver:angle"
+ ":math:geometry"
)
return True
diff --git a/src/modm/math/geometry/angle_int.hpp b/src/modm/math/geometry/angle_int.hpp
new file mode 100644
index 0000000000..97b5935c4a
--- /dev/null
+++ b/src/modm/math/geometry/angle_int.hpp
@@ -0,0 +1,67 @@
+// coding: utf-8
+// ----------------------------------------------------------------------------
+/*
+ * Copyright (c) 2024, Thomas Sommer
+ *
+ * This file is part of the modm project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+// ----------------------------------------------------------------------------
+
+#pragma once
+
+#include
+#include
+#include
+
+namespace modm
+{
+
+/// @brief Represents an absolute angle in a full circle
+/// @group modm_math_geometry
+template
+struct modm_packed IntegerAngle
+{
+ using T = modm::least_uint;
+ using DeltaType = std::make_signed_t>;
+
+ T data;
+ static constexpr T max = std::pow(2, Bits) - 1;
+
+ constexpr DeltaType
+ getDelta()
+ {
+ static DeltaType previous{static_cast(data)};
+ DeltaType delta = DeltaType(data) - previous;
+
+ if (delta < -(max / 2))
+ {
+ delta += max;
+ } else if (delta > (max / 2))
+ {
+ delta -= max;
+ }
+
+ previous = data;
+
+ return delta;
+ }
+
+ /// @return
+ constexpr float
+ toDegree() const
+ {
+ return float(data) * 360 / max;
+ }
+
+ /// @return
+ constexpr float
+ toRadian() const
+ {
+ return float(data) * 2 * std::numbers::pi_v / max;
+ }
+};
+} // namespace modm
\ No newline at end of file