Updated for latest PlatformIO
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
/*************************************
|
/*************************************
|
||||||
* CAN-bus receive
|
* arduino-can-bus-receive
|
||||||
* Author: Michel Bats
|
* Author: Michel Bats
|
||||||
* Website: www.batssoft.nl
|
* Website: www.batssoft.nl
|
||||||
* Version: 0.0.2
|
|
||||||
* Revision: 20190418
|
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <mcp_can.h>
|
#include <mcp_can.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
@@ -40,6 +39,8 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
|||||||
// Initialisatie mcp_can
|
// Initialisatie mcp_can
|
||||||
MCP_CAN CAN(MCP_CAN_SPI_CS_PIN);
|
MCP_CAN CAN(MCP_CAN_SPI_CS_PIN);
|
||||||
|
|
||||||
|
void canIdToReadChange();
|
||||||
|
|
||||||
// SETUP
|
// SETUP
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@@ -98,7 +99,6 @@ void loop()
|
|||||||
|
|
||||||
unsigned int canId = CAN.getCanId();
|
unsigned int canId = CAN.getCanId();
|
||||||
|
|
||||||
|
|
||||||
if (canId == canIdToRead)
|
if (canId == canIdToRead)
|
||||||
{
|
{
|
||||||
bufDisp[0] = buf[0];
|
bufDisp[0] = buf[0];
|
||||||
@@ -133,7 +133,9 @@ void loop()
|
|||||||
if (i == 3)
|
if (i == 3)
|
||||||
{
|
{
|
||||||
display.println(bufDisp[i], HEX);
|
display.println(bufDisp[i], HEX);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
display.print(bufDisp[i], HEX);
|
display.print(bufDisp[i], HEX);
|
||||||
display.print(" ");
|
display.print(" ");
|
||||||
}
|
}
|
||||||
@@ -147,10 +149,12 @@ void loop()
|
|||||||
display.display();
|
display.display();
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
tel++;
|
tel++;
|
||||||
if (tel > 999999) {
|
if (tel > 999999)
|
||||||
|
{
|
||||||
tel = 0;
|
tel = 0;
|
||||||
}
|
}
|
||||||
} else if (tel == 0)
|
}
|
||||||
|
else if (tel == 0)
|
||||||
{
|
{
|
||||||
display.setCursor(0, 0);
|
display.setCursor(0, 0);
|
||||||
display.println(" SEL CUR DIS");
|
display.println(" SEL CUR DIS");
|
||||||
@@ -169,12 +173,15 @@ void loop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void canIdToReadChange() {
|
void canIdToReadChange()
|
||||||
while(digitalRead(INTERRUPT_PIN) == 0){
|
{
|
||||||
|
while (digitalRead(INTERRUPT_PIN) == 0)
|
||||||
|
{
|
||||||
delay(250);
|
delay(250);
|
||||||
}
|
}
|
||||||
canIdCount++;
|
canIdCount++;
|
||||||
if (canIdCount > CAN_ID_COUNT) {
|
if (canIdCount > CAN_ID_COUNT)
|
||||||
|
{
|
||||||
canIdCount = 0;
|
canIdCount = 0;
|
||||||
}
|
}
|
||||||
canIdToRead = canIdToReadArray[canIdCount];
|
canIdToRead = canIdToReadArray[canIdCount];
|
||||||
Reference in New Issue
Block a user