-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile.c
84 lines (66 loc) · 2.18 KB
/
makefile.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma config(Sensor, dgtl1, encoder, sensorQuadEncoder)
#pragma config(Motor, port1, motor1, tmotorVex269_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
// Change these two as needed
#define DURATION 10000
#define TIMESTEP 10
// DON'T CHANGE THESE
// Masks and size of int for writing to file later.
// Its because the library for writing to files on flash
// is hacky and limited.
#define LOWER_MASK 0x00FF
#define UPPER_MASK 0xFF00
#define TYPE_SIZE 2
// END DON'T CHANGE
#include <jpearman-lib/FlashLib.h>
int datapoints = DURATION/TIMESTEP;
static int numData[DURATION / TIMESTEP]; //should equal datapoints, but must be written as constant
static unsigned char numDataStorage[DURATION / TIMESTEP * TYPE_SIZE];
task main()
{
// DON'T CHANGE
unsigned char * data;
int datalength;
char lastname[16];
int result;
// END DON'T CHANGE
/////////////////////////////////////////////////////////////
// This is where you should put your program
// Store the data you wish to save in numData
// Define DURATION and TIMESTEP at the top (must be integers)
wait1Msec(2000);
motor[motor1] = 60;
wait1Msec(500);
SensorValue(encoder) = 0;
for(int i=0; i<datapoints; i++)
{
numData[i] = SensorValue(encoder);
wait1Msec(TIMESTEP);
}
motor[motor1] = 0;
//
//
///////////////////////////////////////////////////////////////
/***************************
* *
* DO NOT EDIT PAST HERE *
* WRITING numData TO FILE *
* *
***************************/
// Prep data for storage
for(int i=0; i<datapoints; i++)
{
numDataStorage[TYPE_SIZE*i] = (unsigned char) (numData[i] & LOWER_MASK);
numDataStorage[TYPE_SIZE*i+1] = (unsigned char) ((numData[i] & UPPER_MASK) >> 8);
}
// Create & Write to File
result = RCFS_AddFile(numDataStorage, datapoints * TYPE_SIZE);
// Dump directory
RCFS_ReadVTOC();
// Get the name of the last file written
RCFS_GetLastFilename(lastname, 16);
// Get a pointer to the data in that last file
// Pass the address of the data pointer (called a handle)
result = RCFS_GetFile(lastname, &data, &datalength);
wait1Msec(500);
}