Little refactoring: Move vibration motor functionality into features
All checks were successful
Compile / Compile (push) Successful in 1m22s

This commit is contained in:
Lewis Jackson 2023-06-02 23:06:53 +03:00
parent 2d11d69067
commit d318322ae5
5 changed files with 28 additions and 13 deletions

View file

@ -0,0 +1,14 @@
#include "VibrationMotor.h"
#include "config.h"
#include <Wire.h>
void WatchFeatures::VibrationMotor::Vibrate(uint8_t intervalMs, uint8_t length)
{
pinMode(VIB_MOTOR_PIN, OUTPUT);
bool motorOn = false;
for (int i = 0; i < length; i++) {
motorOn = !motorOn;
digitalWrite(VIB_MOTOR_PIN, motorOn);
delay(intervalMs);
}
}

View file

@ -0,0 +1,12 @@
#pragma once
#include <stdint.h>
namespace WatchFeatures
{
class VibrationMotor
{
public:
void Vibrate(uint8_t intervalMs = 100, uint8_t length = 20);
};
}

View file

@ -5,6 +5,7 @@
#include "RTC.h"
#include "Storage.h"
#include "Wifi.h"
#include "VibrationMotor.h"
namespace WatchFeatures
{
@ -23,4 +24,5 @@ struct WatchFeatures::WatchFeatures
RTC rtc;
Storage storage;
Wifi wifi;
VibrationMotor vibrationMotor;
};

View file

@ -101,17 +101,6 @@ void Watchy::DisplayBusyCallback(const void *)
esp_light_sleep_start();
}
void Watchy::VibeMotor(uint8_t intervalMs, uint8_t length)
{
pinMode(VIB_MOTOR_PIN, OUTPUT);
bool motorOn = false;
for (int i = 0; i < length; i++) {
motorOn = !motorOn;
digitalWrite(VIB_MOTOR_PIN, motorOn);
delay(intervalMs);
}
}
void Watchy::SyncNTPTime()
{
WiFiUDP ntpUDP;

View file

@ -14,8 +14,6 @@ public:
Watchy();
void Wake();
void DeepSleep();
void VibeMotor(uint8_t intervalMs = 100, uint8_t length = 20);
float GetBatteryVoltage();
void ConnectWiFi();
void SyncNTPTime();
void DisconnectWiFi();