31 #define NXT_SCREEN_ROWS 8
32 #define NXT_SCREEN_COLS 11
33 #define NXT_CHAR_HEIGHT 8
34 #define NXT_CHAR_LENGTH 8
35 #define NXT_SCREEN_X 110
36 #define NXT_SCREEN_Y 64
38 #define PLOT_TYPE_LINE 1
39 #define PLOT_TYPE_POINT 2
40 #define PLOT_TYPE_CIRCLE 3
41 #define PLOT_TYPE_SQUARE 4
55 bool screenInitialized = 0;
57 string screen_TextBuffer[];
64 ArrayInit(screen_TextBuffer,
" ", NXT_SCREEN_ROWS);
65 screenInitialized = 1;
84 while (screen_row >= NXT_SCREEN_ROWS)
88 for (
int i = 1; i < NXT_SCREEN_ROWS; i++)
91 string data = screen_TextBuffer[i];
92 screen_TextBuffer[j] = data;
93 int y = (NXT_SCREEN_ROWS - j - 1) * NXT_CHAR_HEIGHT;
94 TextOut(0, y, data,
false);
106 Acquire(screenMutex);
107 if (screenInitialized == 0) ScreenInit();
108 if (screen_row >= NXT_SCREEN_ROWS) ScreenScroll();
109 screen_TextBuffer[screen_row] = text;
110 int y = ((NXT_SCREEN_ROWS - 1 - screen_row) * NXT_CHAR_HEIGHT);
111 TextOut(0, y, text,
false);
113 if (waitTime > 0) Wait(waitTime);
114 Release(screenMutex);
122 Acquire(screenMutex);
123 if (screenInitialized == 0) ScreenInit();
124 if (screen_row >= NXT_SCREEN_ROWS) ScreenScroll();
125 screen_TextBuffer[screen_row] = NumToStr(num);
126 int y = ((NXT_SCREEN_ROWS - 1 - screen_row) * NXT_CHAR_HEIGHT);
127 NumOut(0, y, num,
false);
129 if (waitTime > 0) Wait(waitTime);
130 Release(screenMutex);
137 void Print(
string format,
long num,
int waitTime)
139 Acquire(screenMutex);
140 if (screenInitialized == 0) ScreenInit();
141 if (screen_row >= NXT_SCREEN_ROWS) ScreenScroll();
142 screen_TextBuffer[screen_row] = formatNum(format, num);
143 int y = ((NXT_SCREEN_ROWS - 1 - screen_row) * NXT_CHAR_HEIGHT);
144 TextOut(0, y, screen_TextBuffer[screen_row],
false);
146 if (waitTime > 0) Wait(waitTime);
147 Release(screenMutex);
155 long minX,
long maxX,
long minY,
long maxY)
163 plotter.plotType = plotType;
171 Acquire(screenMutex);
172 x = (x - plotter.minX) * NXT_SCREEN_X / (plotter.maxX - plotter.minX);
173 y = (y - plotter.minY) * NXT_SCREEN_Y / (plotter.maxY - plotter.minY);
175 if (plotter.plotType != PLOT_TYPE_LINE)
177 if (x < NXT_SCREEN_X && y > 0)
179 if (plotter.plotType == PLOT_TYPE_CIRCLE)
180 CircleOut(x, y, 2,
false);
181 else if (plotter.plotType == PLOT_TYPE_POINT)
182 PointOut(x, y,
false);
183 else if (plotter.plotType == PLOT_TYPE_SQUARE)
184 RectOut(x, y, 2, 2,
false);
187 if (x > NXT_SCREEN_X) x = NXT_SCREEN_X;
190 if (plotter.plotType == PLOT_TYPE_LINE && plotter.lastX != 0 && plotter.lastY != 0)
191 LineOut(plotter.lastX, plotter.lastY, x, y,
false);
195 Release(screenMutex);
226 Print(
"Format: %d", 501, 500);
227 Print(
"Format: %d", 502, 500);
228 Print(
"Format: %d", 503, 500);
229 Print(
"Format: %d", 504, 500);
void PlotterPlotVector(Plotter &plotter, Vector &vec)
Plots the given vector (x,y) using the plotter on screen.
A vector that represents a 2D point by x-y coordinates and a direction angle.
void PrintText(string text, int waitTime)
Prints a line of text. It scrolls the screen if there no line left.
A simple 3-components vector implementation (2D point + direction)
void PlotterPlot(Plotter &plotter, long x, long y)
Plots the given point using the plotter on screen.
void PrintNum(long num, int waitTime)
Prints a number. It scrolls the screen if there no line left.
void PlotterInit(Plotter &plotter, int plotType, long minX, long maxX, long minY, long maxY)
Initializes a plotter. There can be multiple plotters (for each graph) active simultaneous to draw on...
void ScreenClear()
Clears screen.
void Print(string format, long num, int waitTime)
Prints a formated string with a number. It scrolls the screen if there no line left.