Skip to content

Commit

Permalink
Seperate I2C function from haptics.ino
Browse files Browse the repository at this point in the history
The function itself was moved into its own file for I2C to make it easier if someone else needs I2C support for other hardware in the future.

Currently it's still called in the haptics.ino with the PCA9685 setup code as that is the only thing to use it.
  • Loading branch information
Roastlawyer committed Jun 5, 2023
1 parent 3b9e574 commit 85cd6f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 9 additions & 0 deletions firmware/lucidgloves-firmware/I2C.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#include "advancedConfig.h"
#include <Wire.h>


void Setup_I2C() {
Wire.begin(PIN_I2C_SDA, PIN_I2C_SCL);
Serial.println("I2C Initialized");
}
11 changes: 3 additions & 8 deletions firmware/lucidgloves-firmware/haptics.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#if USING_FORCE_FEEDBACK

#if ENABLE_PCA_9865_SERVO
#pragma once
#include "I2C.h"
#include "PCA9685Servo.hpp"
#elif defined(ESP32)
#include <ESP32Servo.h>
Expand All @@ -14,16 +16,9 @@ Servo middleServo;
Servo indexServo;
Servo thumbServo;

struct {
void setup() {
Wire.begin(PIN_I2C_SDA, PIN_I2C_SCL);
Serial.println("I2C Initialized");
}
} i2c;

void setupServoHaptics(){
#if (ENABLE_PCA_9865_SERVO)
i2c.setup();
Setup_I2C();
Initialize_PCA9685_Board();
#endif
pinkyServo.attach(PIN_PINKY_MOTOR);
Expand Down

0 comments on commit 85cd6f0

Please sign in to comment.