Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
WonITKorea committed Apr 12, 2024
2 parents 2933dcc + 3ec6b40 commit 4206f48
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 28 deletions.
10 changes: 7 additions & 3 deletions .vscode/arduino.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"board": "arduino:avr:uno",
"port": "COM18",
"sketch": "code\\Testing_Crate\\GPSTest\\GPSTest.ino"
"sketch": "code\\SKIDAQ_Main\\SKIDAQ_Main.ino",
"board": "rp2040:rp2040:rpipico",
"port": "COM7",
"output": "../build",
"intelliSenseGen": "global",
"programmer": "esptool",
"configuration": "flash=2097152_0,freq=133,opt=Optimize,rtti=Disabled,stackprotect=Enabled,exceptions=Disabled,dbgport=Disabled,dbglvl=None,usbstack=picosdk,ipbtstack=ipv4only,uploadmethod=default"
}
13 changes: 8 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"string_view": "cpp",
"initializer_list": "cpp"
},
"C_Cpp.codeAnalysis.clangTidy.checks.disabled": [
"clang-diagnostic-error"
],
"github.codespaces.defaultExtensions": [

"GitHub.codespaces",
Expand All @@ -31,8 +28,14 @@
"diffEditor.experimental.showMoves": true,
"cmake.configureOnOpen": false,
"arduino.additionalUrls": [
"https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json"
"https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json",
"https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json",
"https://github.com/espressif/arduino-esp32",
"http://arduino.esp8266.com/stable/package_esp8266com_index.json"
],
"arduino.enableUSBDetection": false,
"arduino.useArduinoCli": true
"arduino.useArduinoCli": true,
"arduino.analyzeOnSettingChange": false,
"arduino.skipHeaderProvider": true,
"arduino.analyzeOnOpen": false
}
35 changes: 23 additions & 12 deletions code/SKIDAQ_Main/SKIDAQ_Main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <SoftwareSerial.h>
#include "DFRobot_MCP2515.h"
#include <SPI.h>
#include <TM1637.h>
#include <Wire.h>

// ——————————————————————————————————————————————————————————————————————————————
Expand Down Expand Up @@ -94,6 +95,16 @@ int fuel_Type = 4;
// ——————————————————————————————————————————————————————————————————————————————
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
Adafruit_ADS1115 ads; /* ADS1115 - 16-bit version */
// ——————————————————————————————————————————————————————————————————————————————
// Other Comp. Initalization
// ——————————————————————————————————————————————————————————————————————————————
char picoTemp = analogReadTemp(); // Pi Pico On-Board Temp Sensor
int obled = LED_BUILTIN; // On-Board LED for Basic Error Indication
// Instantiation and pins configurations
// Pin 7 - > DIO
// Pin 6 - > CLK
TM1637 tm(6, 7);

// ——————————————————————————————————————————————————————————————————————————————
// Functions Initalization
// ——————————————————————————————————————————————————————————————————————————————
Expand All @@ -106,12 +117,8 @@ void ADXL345_displaySensorDetails(void);
void ADXL345_displayDataRate(void);
void ADXL345_displayRange(void);
void MCP2515_Init(void);
void TM1637_Init(void);
void blink(int deltime);
// ——————————————————————————————————————————————————————————————————————————————
// Other Comp. Initalization
// ——————————————————————————————————————————————————————————————————————————————
char picoTemp = analogReadTemp(); // Pi Pico On-Board Temp Sensor
int obled = LED_BUILTIN; // On-Board LED for Basic Error Indication

// ——————————————————————————————————————————————————————————————————————————————
// Switch Module Configuration
Expand All @@ -120,7 +127,6 @@ int obled = LED_BUILTIN; // On-Board LED for Basic Error Indication
#define MOSUP_PIN 12
#define MOSDOWN_PIN 13
#define DRS_PIN 14
#define DiagEN 7 // Toggle Switch for OBD2 Simulation
int DIAGENB = 0; //

// ——————————————————————————————————————————————————————————————————————————————
Expand All @@ -134,25 +140,25 @@ void setup()
pinMode(MOSDOWN_PIN, OUTPUT);
pinMode(DRS_PIN, OUTPUT);
pinMode(DynoInt, OUTPUT);
pinMode(DiagEN, INPUT);
Serial.begin(115200);
while (!Serial)
{
;
}

delay(100);
TM1637_Init();
DHT_TaskInit();
ADS1115_Init();
ADXL345_Init();
MCP2515_Init();
blink(1000);
Serial.println("——————————————————————————————————————————————————————————————————————————————");
Serial.println("* SKIDAQ " + String(FW_Version) + " *");
Serial.println("* By ChaeWon Lim https://github.com/WonITKorea *");
Serial.println("* Based on Open-Ecu-Sim-OBD2-FW *");
Serial.println("* By Rick Spooner https://github.com/spoonieau *");
Serial.println("——————————————————————————————————————————————————————————————————————————————");
blink(1000);
tm.display("OKAY");
delay(3000);
}

Expand Down Expand Up @@ -327,7 +333,7 @@ void loop()
delay(100);
}
//=================================================================
// Return CAN-BUS Messages - SUPPORTED PID's
// Return CAN-BUS Messages - SUPPORTED PIDs
//=================================================================

if (canMessageRead == "2,1,0,")
Expand Down Expand Up @@ -511,7 +517,7 @@ void loop()
}

// ——————————————————————————————————————————————————————————————————————————————
// Functions Configuration
// Extra Functions Configuration
// ——————————————————————————————————————————————————————————————————————————————
void DHT_TaskInit(void)
{
Expand Down Expand Up @@ -735,6 +741,12 @@ void MCP2515_Init(void)
Serial.println("CAN Status: OK");
}

void TM1637_Init(void)
{
tm.begin();
tm.setBrightnessPercent(90);
}

void blink(int deltime)
{
digitalWrite(LED_BUILTIN, HIGH);
Expand All @@ -743,7 +755,6 @@ void blink(int deltime)
delay(deltime);
}

// Extra Configurations
#ifndef ARDUINO_ARCH_RP2040
#error "Select a Raspberry Pi Pico board"
#endif
24 changes: 16 additions & 8 deletions code/Testing_Crate/STIMU/STIMU.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@

#define DEV_I2C Wire
#define SerialPort Serial
#define INT_1 22
#define INT_1 6
float CAL = 0;
char Acc2of = 0;

// Components
ASM330LHHSensor AccGyr(&DEV_I2C, ASM330LHH_I2C_ADD_L);

void setup() {
void setup()
{
// Led.
pinMode(LED_BUILTIN, OUTPUT);

// Force INT1 of ASM330LHH low in order to enable I2C
// Force INT1 of ASM330LHFH low in order to enable I2C
pinMode(INT_1, OUTPUT);

digitalWrite(INT_1, LOW);
Expand All @@ -62,17 +65,18 @@ void setup() {

// Initialize serial for output.
SerialPort.begin(115200);

// Initialize I2C bus.
DEV_I2C.begin();

AccGyr.begin();
AccGyr.Set_X_FS(2);
AccGyr.Set_X_FS(4);
AccGyr.Enable_X();
AccGyr.Enable_G();
}

void loop() {
void loop()
{
// Led blinking.
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
Expand All @@ -84,14 +88,18 @@ void loop() {
int32_t gyroscope[3] = {};
AccGyr.Get_X_Axes(accelerometer);
AccGyr.Get_G_Axes(gyroscope);

if (SerialPort.readString() == "l")
{
delay(3000);
Acc2of = - accelerometer[2];
}
// Output data.
SerialPort.print("ASM330LHH: | Acc[mg]: ");
SerialPort.print(accelerometer[0]);
SerialPort.print(" ");
SerialPort.print(accelerometer[1]);
SerialPort.print(" ");
SerialPort.print(accelerometer[2]);
SerialPort.print(accelerometer[2] - Acc2of);
SerialPort.print(" | Gyr[mdps]: ");
SerialPort.print(gyroscope[0]);
SerialPort.print(" ");
Expand Down

0 comments on commit 4206f48

Please sign in to comment.