-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.c
62 lines (57 loc) · 1.14 KB
/
tools.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* tools.c
*
* Created on: Sep 17, 2013
* Author: nizinski_w
*/
#include <config.h>
static volatile BOOL bStop;
/** called from ISR to stop interruptible delay
*
*/
void breakable_delay_break(void)
{
bStop = TRUE;
}
/**
* Interruptible delay (by keypress)
* @param __ms
*/
void breakable_delay_ms(unsigned int __ms)
{
bStop = FALSE;
while ((bStop==FALSE) && (__ms-->0))
{
_delay_ms(1);
}
}
/**
* Increment *pucValue (by adding iStep) and make wrap around within range ucMin and ucMax
*
* @param pcValue
* @param iStep TRUE - increment up
* @param cMin
* @param cMax
*/
void vIncrementWithRange (char *pcValue, int iStep, char cMin, char cMax)
{
iStep += *pcValue;
//CLOCK_PRINTF_P (PSTR("iStep=%d ucMax=%d ucMin=%d\n"), iStep, ucMax, ucMin);
if (iStep > cMax)
{
//CLOCK_PRINTF_P(PSTR("MAX\n"));
*pcValue = cMin;
}
else
if (iStep < cMin)
{
//CLOCK_PRINTF_P(PSTR("MIN\n"));
*pcValue = cMax;
}
else
{
//CLOCK_PRINTF_P(PSTR("OK\n"));
*pcValue = iStep;
//CLOCK_PRINTF_P(PSTR("result %d\n"), *pucValue);
}
}