File tree 3 files changed +66
-0
lines changed
3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // Tools for USB HID Autofire
3
+ //
4
+
5
+ void strrev (char * arr , int start , int end ) {
6
+ char temp ;
7
+
8
+ if (start >= end )
9
+ return ;
10
+
11
+ temp = * (arr + start );
12
+ * (arr + start ) = * (arr + end );
13
+ * (arr + end ) = temp ;
14
+
15
+ start ++ ;
16
+ end -- ;
17
+ strrev (arr , start , end );
18
+ }
19
+
20
+ char * itoa (int number , char * arr , int base )
21
+ {
22
+ int i = 0 , r , negative = 0 ;
23
+
24
+ if (number == 0 )
25
+ {
26
+ arr [i ] = '0' ;
27
+ arr [i + 1 ] = '\0' ;
28
+ return arr ;
29
+ }
30
+
31
+ if (number < 0 && base == 10 )
32
+ {
33
+ number *= -1 ;
34
+ negative = 1 ;
35
+ }
36
+
37
+ while (number != 0 )
38
+ {
39
+ r = number % base ;
40
+ arr [i ] = (r > 9 ) ? (r - 10 ) + 'a' : r + '0' ;
41
+ i ++ ;
42
+ number /= base ;
43
+ }
44
+
45
+ if (negative )
46
+ {
47
+ arr [i ] = '-' ;
48
+ i ++ ;
49
+ }
50
+
51
+ strrev (arr , 0 , i - 1 );
52
+
53
+ arr [i ] = '\0' ;
54
+
55
+ return arr ;
56
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef FLIPPERZERO_FIRMWARE_TOOLS_H
2
+ #define FLIPPERZERO_FIRMWARE_TOOLS_H
3
+
4
+ void strrev (char * arr , int start , int end );
5
+ char * itoa (int number , char * arr , int base );
6
+
7
+ #endif //FLIPPERZERO_FIRMWARE_TOOLS_H
Original file line number Diff line number Diff line change 4
4
#include <gui/gui.h>
5
5
#include <input/input.h>
6
6
#include "version.h"
7
+ #include "tools.h"
7
8
8
9
// Uncomment to be able to make a screenshot
9
10
//#define USB_HID_AUTOFIRE_SCREENSHOT
@@ -25,7 +26,9 @@ uint32_t autofire_delay = 10;
25
26
static void usb_hid_autofire_render_callback (Canvas * canvas , void * ctx ) {
26
27
UNUSED (ctx );
27
28
char autofire_delay_str [12 ];
29
+ //std::string pi = "pi is " + std::to_string(3.1415926);
28
30
itoa (autofire_delay , autofire_delay_str , 10 );
31
+ //sprintf(autofire_delay_str, "%lu", autofire_delay);
29
32
30
33
canvas_clear (canvas );
31
34
You can’t perform that action at this time.
0 commit comments