This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDSLCDPrinter.cpp
104 lines (87 loc) · 2.63 KB
/
DSLCDPrinter.cpp
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "DSLCDPrinter.h"
#include "Debugging.h"
#include <vector>
#include <string>
#include <queue>
#include <iostream>
#include <stdio.h>
using namespace std;
#include <sstream>
std::string Convert (float number){
std::ostringstream buff;
buff<<number;
return buff.str();
}
std::string Convert (int number){
std::ostringstream buff;
buff<<number;
return buff.str();
}
std::string Convert (double number){
std::ostringstream buff;
buff<<number;
return buff.str();
}
void DSLCDPrinter::Update() {
// updates window
printQueue.clear();
for (int i = 0; i < lcdMessages.size(); i++) {
LCDMessage* lcdMessage = lcdMessages[i];
lcdMessage->AddMessages(&printQueue);
}
for (int i = DriverStationLCD::kUser_Line1;
(i <= DriverStationLCD::kUser_Line6) &&
((i - DriverStationLCD::kUser_Line1) < printQueue.size());
i++) {
string message = printQueue[i - DriverStationLCD::kUser_Line1];
dsLCD->Printf(static_cast<DriverStationLCD::Line>(i), 1, message.c_str());
}
dsLCD->UpdateLCD();
}
void DSLCDPrinter::Clear() {
printQueue.clear();
dsLCD->Clear();
}
void DSLCDPrinter::AddLCDMessage(LCDMessage* myLCDMessage) {
lcdMessages.push_back(myLCDMessage);
}
RobotModelLCDMessage::RobotModelLCDMessage(RobotModel* myRobot) {
robot = myRobot;
}
void RobotModelLCDMessage::AddMessages(vector<string>* printQueue){
// set buffer equal to message then push buffer
// the string has a length limit for the screen to print it
char buffer [100];
sprintf(buffer, "Gyro angle: %f", robot->gyro->GetAngle());
//printf("%s\n", buffer);
printQueue->push_back(buffer);
sprintf(buffer, "Left enc: %f", robot->GetWheelEncoderDistance(RobotModel::kLeftWheel));
printQueue->push_back(buffer);
float rightEncoderValue = (float)(robot->GetWheelEncoderDistance(RobotModel::kRightWheel));
sprintf(buffer, "Right enc: %f", rightEncoderValue);
printQueue->push_back(buffer);
if (robot->OpticalSensorActivated()) {
sprintf(buffer, "Optical: %s", "true ");
} else {
sprintf(buffer, "Optical: %s", "false");
}
printQueue->push_back(buffer);
if (robot->limitSwitch->Get() == 1) {
sprintf(buffer, "Limit: %s", "true");
} else {
sprintf(buffer, "Limit: %s", "false");
}
printQueue->push_back(buffer);
}
CameraControllerLCDMessage::CameraControllerLCDMessage(CameraController* myCameraController) {
cameraController = myCameraController;
}
void CameraControllerLCDMessage::AddMessages(vector<string>* printQueue) {
char buffer[100];
if (cameraController->targetFound) {
sprintf(buffer, "Hot target: %s", "true");
} else {
sprintf(buffer, "Hot target: %s", "false");
}
//printQueue->push_back(buffer);
}