Skip to content

Commit

Permalink
led strip logic updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ig-or committed Mar 7, 2024
1 parent ed3a904 commit ef2a8c0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/eth_api.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


#include "eth_api.h"

int makeFmessage(MsgTypes type, char* buf, int bufSize, ...) {

}
52 changes: 52 additions & 0 deletions src/eth_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@


#pragma once

#include <unistd.h>
#include <stdarg.h>
#include "xmessage.h"

enum MsgTypes {
mgFrontObstacle,
mgRearObstacle
};
#pragma pack(1)
struct MsgHeader {

};

struct MFrontObstacle {
static const MsgTypes type = mgFrontObstacle;
float distance;
};


#pragma pack()

/**
* @brief make a message with several 'float' numbers
*
* @param type message type
* @param buf where to put everything
* @param bufSize size of 'buf'
* @param ... all the float numbers
* @return message size in bytes
*/
int makeFmessage(MsgTypes type, char* buf, int bufSize, ...);

/**
* @brief
*
* @param msg
* @param type
* @return char* a pointer to the message body
*/
char* makeMsgHeader(char* msg, MsgTypes type);
/**
* @brief
*
* @param msg
* @param type
* @return char*
*/
char* makeTail(char* msg, MsgTypes type);
10 changes: 5 additions & 5 deletions teensy/src/eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void ethSetup() {
pingStruct.id = 0; pingStruct.time = millis(); pingStruct.reserved[0] = 0;

client = server.available();
ledstripMode(lsEyeConnection, 200, 0x00000008);
ledstripMode(lsEyeConnection, 128, 0x00000008);
lastIncomingInfoTime = 0;
xmprintf(1, "eth started 2; client=%s \r\n", client ? "yes" : "no");
}
Expand All @@ -146,7 +146,7 @@ void ethFeed(char* s, int size) {
void ethLoop(unsigned int now) {
if ((now - lastIncomingInfoTime) > 1250) {
//xmprintf(1, "ethLoop() disconnected?")
ledstripMode(lsEyeConnection, 200, 0x00a000a0);
ledstripMode(lsEyeConnection, 128, 0x00900080);
}

EthernetLinkStatus currentLinkStatus = Ethernet.linkStatus();
Expand All @@ -160,7 +160,7 @@ void ethLoop(unsigned int now) {
if (clientConnected) {
clientConnected = false;
xmprintf(1, "ETH client disconnected 3; linkStatus = %d\r\n", linkStatus);
ledstripMode(lsEyeConnection, 200, 0x00000095);
ledstripMode(lsEyeConnection, 128, 0x00000075);
}
return;
}
Expand All @@ -174,7 +174,7 @@ void ethLoop(unsigned int now) {
if (clientConnected) {
clientConnected = false;
xmprintf(1, "ETH client disconnected 2 \r\n");
ledstripMode(lsEyeConnection, 200, 0x00000095);
ledstripMode(lsEyeConnection, 128, 0x00000075);
}
return;
}
Expand Down Expand Up @@ -216,7 +216,7 @@ void ethLoop(unsigned int now) {
//xmprintf(2, "ETH: got %d bytes {%s} \r\n", bs1, packetBuffer);
if ((bs1 > 0)) {
lastIncomingInfoTime = now;
ledstripMode(lsEyeConnection, 200, 0x0000a000);
ledstripMode(lsEyeConnection, 128, 0x00007500);
if (strncmp(packetBuffer, "console", 7) == 0 ) { // console client connected
client.write("tee ", 4);
} else if (strncmp(packetBuffer, "ping", 4) == 0 ) {
Expand Down
5 changes: 3 additions & 2 deletions teensy/src/led_strip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ void ledstripSetup() {
FastLED.addLeds<LED_CHIPSET, PIN_DATA, PIN_CLOCK, LED_ORDER>(leds, NUM_LEDS);

for (int i = 0; i < NUM_LEDS; ++i) {
leds[i] = CRGB::Green;
leds[i] = 0x00000300;
}
leds[1] = 0x00090008;
FastLED.show();
}

Expand Down Expand Up @@ -131,7 +132,7 @@ void ledstripProcess(unsigned int now) {
// this led is still empty..
}

const int ecp = 1000;
const int ecp = 585;
if (lsModes[lsEyeConnection] != 0) { // connection: special case
k = now % (ecp << 1);
float u;
Expand Down

0 comments on commit ef2a8c0

Please sign in to comment.