1st of all: can you add the Boeing 747.
2nd of all: ai DOES in fact understand the CE/C Toolchain:
Microsoft Copilot chat wrote:
i want you to code a C program for the ti 84 pce that displays a line starting at the center of the screen that points in direction i (defined by a for loop that runs 359 times and resest to 0 after that), continues for 50 pixels and exits when [clr] is pressed
Sure, here's a C program for the TI-84 Plus CE calculator that achieves your request. This program uses the TI-84's built-in graphics library from the CE C Toolchain (available via the CE Development Resources). It draws a line starting at the center of the screen, rotating as defined by the i loop, extending for 50 pixels, and exits when the [CLEAR] button is pressed.
c
#include <graphx.h>
#include <keypadc.h>
#include <math.h>
#include <tice.h>
#define PI 3.14159265
int main(void) {
int x0, y0; // Center of the screen
int x1, y1; // End coordinates of the line
int i = 0; // Direction variable
// Initialize graphics
gfx_Begin();
gfx_SetDrawBuffer();
// Get the center of the screen
x0 = LCD_WIDTH / 2;
y0 = LCD_HEIGHT / 2;
// Main loop
while (true) {
// Check if [CLEAR] is pressed
kb_Scan();
if (kb_IsDown(kb_KeyClear)) {
break;
}
// Calculate the end coordinates of the line
x1 = x0 + (int)(50 * cos(i * PI / 180)); // Convert degrees to radians
y1 = y0 - (int)(50 * sin(i * PI / 180)); // Screen coordinates invert the Y-axis
// Clear the screen and draw the line
gfx_FillScreen(gfx_black);
gfx_SetColor(gfx_white);
gfx_Line(x0, y0, x1, y1);
// Swap the drawing buffer to display the frame
gfx_SwapDraw();
// Increment and reset i if necessary
i = (i + 1) % 360;
// Add a short delay for smoother animation
delay(10);
}
// End graphics
gfx_End();
return 0;
}
Explanation:
Graphics Library: The program uses the graphx library to draw the line on the screen.
Keyboard Scanning: It detects the [CLEAR] button using kb_Scan().
Math Calculations: The line's endpoint is calculated using trigonometry (cosine and sine) and degree-to-radian conversion.
Animation: The screen is cleared and redrawn in each loop iteration, creating the animation effect.
Requirements:
Install the CE C Toolchain to compile and run this program.
Transfer the compiled program (usually a .8xp file) to your TI-84 Plus CE.
Feel free to adapt or tweak the program to suit your needs! Let me know if you have questions or run into issues.
make the spinning direction adjustable and toggle when [2nd] is pressed also make the length adjustable with the left (decrease by 1) and right (increase by 1) arrow keys
Here's an updated version of the program incorporating your requests. Now, the spinning direction toggles when [2nd] is pressed, and the line length is adjustable using the left (decrease by 1) and right (increase by 1) arrow keys.
c
#include <graphx.h>
#include <keypadc.h>
#include <math.h>
#include <tice.h>
#define PI 3.14159265
int main(void) {
int x0, y0; // Center of the screen
int x1, y1; // End coordinates of the line
int i = 0; // Direction variable
int length = 50; // Initial line length
int direction = 1; // Clockwise (1) or counterclockwise (-1)
// Initialize graphics
gfx_Begin();
gfx_SetDrawBuffer();
// Get the center of the screen
x0 = LCD_WIDTH / 2;
y0 = LCD_HEIGHT / 2;
// Main loop
while (true) {
// Check for key presses
kb_Scan();
// Exit when [CLEAR] is pressed
if (kb_IsDown(kb_KeyClear)) {
break;
}
// Toggle spinning direction when [2ND] is pressed
if (kb_IsDown(kb_Key2nd)) {
direction = -direction; // Reverse direction
// Wait for release to avoid repeated toggling
while (kb_IsDown(kb_Key2nd)) kb_Scan();
}
// Adjust line length with left and right arrow keys
if (kb_IsDown(kb_KeyLeft) && length > 1) { // Prevent negative/zero length
length--;
}
if (kb_IsDown(kb_KeyRight) && length < 100) { // Cap length at 100 for practical reasons
length++;
}
// Calculate the end coordinates of the line
x1 = x0 + (int)(length * cos(i * PI / 180)); // Convert degrees to radians
y1 = y0 - (int)(length * sin(i * PI / 180)); // Inverted Y-axis for screen coordinates
// Clear the screen and draw the line
gfx_FillScreen(gfx_black);
gfx_SetColor(gfx_white);
gfx_Line(x0, y0, x1, y1);
// Swap the drawing buffer to display the frame
gfx_SwapDraw();
// Increment (or decrement) i based on direction
i = (i + direction + 360) % 360; // Keep i in range [0, 359]
// Add a short delay for smoother animation
delay(10);
}
// End graphics
gfx_End();
return 0;
}
Adjustments Added:
Spinning Direction Toggle: Pressing [2ND] changes the spinning direction (clockwise or counterclockwise) by reversing the direction variable.
Length Adjustment: The line length decreases by 1 when the left arrow is pressed and increases by 1 when the right arrow is pressed, with limits to prevent it from becoming too short or excessively long.
Key Release Handling: For [2ND], the program waits for the key to be released before detecting the next press, preventing rapid toggling.
Notes:
You can modify the maximum length value (currently 100) if you'd like the line to extend even further.
For smoother animations, the delay(10) can be adjusted, but note that shorter delays may increase CPU usage.
This should give you full control over both direction and length of the spinning line. Let me know how it works for you!
make the max lenghth 160 pixels, reverse the initial direction, and make the speed adjustable with up (faster) and down (slower) arrows
Here's the updated version of the program reflecting your new requirements:
Maximum length: Increased to 160 pixels.
Initial direction: Reversed (starts counterclockwise).
Speed adjustment: Controlled by the up (faster) and down (slower) arrow keys.
c
#include <graphx.h>
#include <keypadc.h>
#include <math.h>
#include <tice.h>
#define PI 3.14159265
int main(void) {
int x0, y0; // Center of the screen
int x1, y1; // End coordinates of the line
int i = 0; // Direction variable
int length = 50; // Initial line length
int direction = -1; // Counterclockwise (-1) initial direction
int delay_time = 10; // Initial delay (controls speed)
// Initialize graphics
gfx_Begin();
gfx_SetDrawBuffer();
// Get the center of the screen
x0 = LCD_WIDTH / 2;
y0 = LCD_HEIGHT / 2;
// Main loop
while (true) {
// Check for key presses
kb_Scan();
// Exit when [CLEAR] is pressed
if (kb_IsDown(kb_KeyClear)) {
break;
}
// Toggle spinning direction when [2ND] is pressed
if (kb_IsDown(kb_Key2nd)) {
direction = -direction; // Reverse direction
// Wait for release to avoid repeated toggling
while (kb_IsDown(kb_Key2nd)) kb_Scan();
}
// Adjust line length with left and right arrow keys
if (kb_IsDown(kb_KeyLeft) && length > 1) { // Prevent negative/zero length
length--;
}
if (kb_IsDown(kb_KeyRight) && length < 160) { // Cap length at 160 pixels
length++;
}
// Adjust speed with up and down arrow keys
if (kb_IsDown(kb_KeyUp) && delay_time > 1) { // Prevent too fast speeds
delay_time--;
}
if (kb_IsDown(kb_KeyDown) && delay_time < 100) { // Cap delay at 100 for practical reasons
delay_time++;
}
// Calculate the end coordinates of the line
x1 = x0 + (int)(length * cos(i * PI / 180)); // Convert degrees to radians
y1 = y0 - (int)(length * sin(i * PI / 180)); // Inverted Y-axis for screen coordinates
// Clear the screen and draw the line
gfx_FillScreen(gfx_black);
gfx_SetColor(gfx_white);
gfx_Line(x0, y0, x1, y1);
// Swap the drawing buffer to display the frame
gfx_SwapDraw();
// Increment (or decrement) i based on direction
i = (i + direction + 360) % 360; // Keep i in range [0, 359]
// Add a delay based on the current speed
delay(delay_time);
}
// End graphics
gfx_End();
return 0;
}
Updates:
Maximum Line Length: Adjusted the upper limit for line length to 160 pixels.
Initial Direction: Changed direction to -1 to start counterclockwise.
Speed Adjustment: Incorporated a delay_time variable that is increased or decreased using up and down arrow keys. The program caps the delay between 1 and 100 to maintain control over the speed.
Notes:
With delay_time, a lower value means faster spinning, and a higher value means slower spinning. You can modify the range if needed.
The default settings provide a smooth animation, but you can tweak the initial delay and other variables for your preferred experience.
This program should now give you full control over the line's behavior, direction, length, and speed. Let me know if there's anything else you'd like added!
make it able to spin faster (maybe allow a delay of 0)\
Here's the updated code allowing the spinning speed to go even faster, including the option for a delay of 0 (essentially making the animation as fast as the calculator's processing power allows):
c
#include <graphx.h>
#include <keypadc.h>
#include <math.h>
#include <tice.h>
#define PI 3.14159265
int main(void) {
int x0, y0; // Center of the screen
int x1, y1; // End coordinates of the line
int i = 0; // Direction variable
int length = 50; // Initial line length
int direction = -1; // Counterclockwise (-1) initial direction
int delay_time = 10; // Initial delay (controls speed)
// Initialize graphics
gfx_Begin();
gfx_SetDrawBuffer();
// Get the center of the screen
x0 = LCD_WIDTH / 2;
y0 = LCD_HEIGHT / 2;
// Main loop
while (true) {
// Check for key presses
kb_Scan();
// Exit when [CLEAR] is pressed
if (kb_IsDown(kb_KeyClear)) {
break;
}
// Toggle spinning direction when [2ND] is pressed
if (kb_IsDown(kb_Key2nd)) {
direction = -direction; // Reverse direction
// Wait for release to avoid repeated toggling
while (kb_IsDown(kb_Key2nd)) kb_Scan();
}
// Adjust line length with left and right arrow keys
if (kb_IsDown(kb_KeyLeft) && length > 1) { // Prevent negative/zero length
length--;
}
if (kb_IsDown(kb_KeyRight) && length < 160) { // Cap length at 160 pixels
length++;
}
// Adjust speed with up and down arrow keys
if (kb_IsDown(kb_KeyUp) && delay_time > 0) { // Allow delay_time to reach 0
delay_time--;
}
if (kb_IsDown(kb_KeyDown) && delay_time < 100) { // Cap delay at 100 for practical reasons
delay_time++;
}
// Calculate the end coordinates of the line
x1 = x0 + (int)(length * cos(i * PI / 180)); // Convert degrees to radians
y1 = y0 - (int)(length * sin(i * PI / 180)); // Inverted Y-axis for screen coordinates
// Clear the screen and draw the line
gfx_FillScreen(gfx_black);
gfx_SetColor(gfx_white);
gfx_Line(x0, y0, x1, y1);
// Swap the drawing buffer to display the frame
gfx_SwapDraw();
// Increment (or decrement) i based on direction
i = (i + direction + 360) % 360; // Keep i in range [0, 359]
// Add a delay based on the current speed
if (delay_time > 0) {
delay(delay_time);
}
}
// End graphics
gfx_End();
return 0;
}
Changes:
Delay Adjustment: The delay_time can now go down to 0, allowing for maximum spinning speed. When the delay is 0, the animation becomes as fast as the calculator can handle.
Up/Down Speed Adjustment: Speed control remains intuitive—[UP] reduces the delay (increases speed), and [DOWN] increases the delay (slows it down).
Safety Check: The delay() function is bypassed if delay_time == 0 to ensure it doesn't interfere with the animation.
Feel free to test it out—this should give you ultra-smooth control over both speed and direction! Let me know if you need further refinements.
Edit: i did this today in less than 30 minutes with no errors only warnings.