Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jake Read
ucbus-stepper
Commits
c6ec8cf0
Commit
c6ec8cf0
authored
Nov 18, 2021
by
Jake Read
Browse files
new bus-drop code
parent
073f103c
Changes
4
Hide whitespace changes
Inline
Side-by-side
firmware/stepper-drop/src/main.cpp
View file @
c6ec8cf0
...
...
@@ -151,7 +151,6 @@ void setup() {
ERRLIGHT_SETUP
;
CLKLIGHT_SETUP
;
DEBUG1PIN_SETUP
;
// limit switch
//limitSetup();
// osap
...
...
@@ -183,14 +182,12 @@ uint8_t testRx[256];
void
loop
()
{
osapLoop
();
stepper_hw
->
dacRefresh
();
/*
// still not sure: this registers as "made" on init (?)
if
(
limitIsMade
()){
ERRLIGHT_ON
;
}
else
{
ERRLIGHT_OFF
;
}
*/
}
// end loop
...
...
osape-d51
@
50426e4f
Compare
eeabe1a1
...
50426e4f
Subproject commit
eeabe1a173dc1c7270b0099a7a1a0e0e7735e1be
Subproject commit
50426e4ff771eeb2c94180e59a05258d2daf24ff
firmware/stepper-drop/src/syserror.cpp
View file @
c6ec8cf0
#include "syserror.h"
#include "indicators.h"
#include "osape-d51/osape/osap/ts.h"
#include "osape-d51/vertices/ucBusDrop.h"
#include "osape-d51/osape/utils/cobs.h"
#include "config.h"
#include "indicators.h"
uint8_t
errBuf
[
1028
];
uint8_t
errEncoded
[
1028
];
/*
boolean writeString(unsigned char* dest, uint16_t* dptr, String msg){
uint16_t len = msg.length();
dest[(*dptr) ++] = TS_STRING_KEY;
writeLenBytes(dest, dptr, len);
msg.getBytes(dest, len + 1);
return true;
volatile
unsigned
long
errLightLastOn
=
0
;
volatile
unsigned
long
errLightOnTime
=
0
;
volatile
boolean
errLightBlink
=
true
;
volatile
boolean
errLightOn
=
false
;
void
sysErrLightFlash
(
uint8_t
level
){
ERRLIGHT_ON
;
errLightOn
=
true
;
errLightLastOn
=
millis
();
switch
(
level
){
case
0
:
errLightBlink
=
false
;
break
;
case
1
:
errLightOnTime
=
5000
;
break
;
case
2
:
errLightOnTime
=
1000
;
break
;
case
3
:
errLightOnTime
=
250
;
break
;
}
}
void
sysErrLightCheck
(
void
){
if
(
errLightOn
&&
errLightBlink
){
if
(
errLightLastOn
+
errLightOnTime
<
millis
()){
ERRLIGHT_OFF
;
errLightOn
=
false
;
}
}
}
boolean writeLenBytes(unsigned char* dest, uint16_t* dptr, uint16_t len){
dest[(*dptr) ++] = len;
dest[(*dptr) ++] = (len >> 8) & 255;
return true;
#ifdef UCBUS_IS_DROP
void
sysError
(
String
msg
){
// noop
}
*/
#else
// config-your-own-ll-escape-hatch
void
sysError
(
String
msg
){
...
...
@@ -38,11 +65,18 @@ void sysError(String msg){
errBuf
[
6
]
=
(
len
>>
24
)
&
255
;
msg
.
getBytes
(
&
(
errBuf
[
7
]),
len
+
1
);
size_t
ecl
=
cobsEncode
(
errBuf
,
len
+
7
,
errEncoded
);
errEncoded
[
ecl
]
=
0
;
// add delimiter
// escape:
Serial
.
write
(
errEncoded
,
ecl
+
1
);
errEncoded
[
ecl
]
=
0
;
// direct escape
//if(Serial.availableForWrite() > (int64_t)ecl){
Serial
.
write
(
errEncoded
,
ecl
+
1
);
//Serial.flush();
//} else {
// ERRLIGHT_ON;
//}
}
#endif
void
logPacket
(
uint8_t
*
pck
,
uint16_t
len
){
String
errmsg
;
errmsg
.
reserve
(
1024
);
...
...
@@ -53,4 +87,5 @@ void logPacket(uint8_t* pck, uint16_t len){
errmsg
+=
", "
;
}
sysError
(
errmsg
);
}
\ No newline at end of file
}
firmware/stepper-drop/src/syserror.h
View file @
c6ec8cf0
...
...
@@ -7,4 +7,9 @@ void sysError(String msg);
void
logPacket
(
uint8_t
*
pck
,
uint16_t
len
);
//void sysError(uint8_t* bytes, uint16_t len);
void
sysErrLightFlash
(
uint8_t
level
);
void
sysErrLightCheck
(
void
);
#define ERROR(level, msg) sysErrLightFlash(level); sysError(msg)
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment