-
Notifications
You must be signed in to change notification settings - Fork 11
/
lasershark_stdin_circlemaker.c
56 lines (45 loc) · 1.56 KB
/
lasershark_stdin_circlemaker.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
/*
lasershark_stdin_circlemaker.c - Application that draws a circle intended
for consumption by lasershark_stdin.
Copyright (C) 2012 Jeffrey Nelson <[email protected]>
This file is part of Lasershark's USB Host App.
Lasershark is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Lasershark is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Lasershark. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <math.h>
static uint16_t float_to_lasershark_xy(float var)
{
uint16_t val = (4095 * (var + 1.0)/2.0);
return val;
}
int main (int argc, char *argv[])
{
double x_f, y_f;
uint32_t index = 0;
float step = 2*M_PI/1000;
printf("r=20000\n");
printf("e=1\n");
x_f = 0;
y_f = 0;
while(1) {
x_f = sinf(index*step);
y_f = cosf(index*step);
printf("s=%u,%u,%u,%u,%u,%u\n",
float_to_lasershark_xy(x_f), float_to_lasershark_xy(y_f), 4095,4095,1,1); // x, y, a, b, c, intl_a
index++;
}
// These should really be stuck at the end of the output.. but this is just a demo.
//printf("f=1\n");
//printf("e=0\n");
return 0;
}