// struct Point
// { // point in 2D space
// int16_t x;
// int16_t y;
// };
// struct WheelAnim
// { // Animation steps for revolver cylinder menu
// // Every elemnt is counted from left to right
// Point hole1[9];
// Point hole2[9];
// Point hole3[9];
// Point hole4[9];
// Point hole5[9];
// Point edge1[9];
// Point edge2[9];
// Point edge3[9];
// Point edge4[9];
// };
// Point hole1[9] = {{-18, 14}, {-16, 17}, {-11, 20}, {-6, 22}, {-20, -11}, {-20, -11}, {-20, -11}, {-20, -11}, {-20, -11}};
// Point hole2[9] = {{-5, 22}, {-11, 20}, {-16, 16}, {-18, 14}, {-20, 12}, {-18, 14}, {-16, 17}, {-11, 20}, {-6, 22}};
// Point hole3[9] = {{19, 11}, {16, 16}, {11, 20}, {5, 22}, {0, 23}, {-5, 22}, {-11, 20}, {-16, 16}, {-19, 11}};
// Point hole4[9] = {{22, -5}, {23, 0}, {22, 6}, {21, 9}, {20, 12}, {18, 14}, {16, 17}, {11, 20}, {6, 22}};
// Point hole5[9] = {{20, -11}, {20, -11}, {20, -11}, {20, -11}, {20, -11}, {22, -5}, {23, 0}, {22, 6}, {19, 11}};
// Point edge1[9] = {{-40, 23}, {-40, 23}, {-40, 23}, {-44, -12}, {-46, 0}, {-44,12}, {-40,23}, {-36, 28}, {-30,35}};
// Point edge2[9] = {{-44, 12}, {-40, 23}, {-36, 28}, {-30,35}, {-23, 40}, {-20, 42}, {-9, 45}, {2,46}, {13,44}};
// Point edge3[9] = {{-20, 42}, {-9, 45}, {2, 46}, {13, 44}, {23, 40}, {30, 35}, {36, 28}, {40, 23}, {44, 12}};
// Point edge4[9] = {{30, 35}, {36, 28}, {40, 23}, {44, 12}, {46, 0}, {44, -12}, {40, -23}, {40, -23}, {40, -23}};
// Point *h1 = &hole1[4];
// Point *h2 = &hole2[4];
// Point *h3 = &hole3[4];
// Point *h4 = &hole4[4];
// Point *h5 = &hole5[4];
// Point *e1 = &edge1[4];
// Point *e2 = &edge2[4];
// Point *e3 = &edge3[4];
// Point *e4 = &edge4[4];
// WheelAnim wheelAnim =
// {
// &hole1[4],
// &hole2[4],
// &hole3[4],
// &hole4[4],
// &hole5[4],
// &edge1[4],
// &edge2[4],
// &edge3[4],
// &edge4[4]
// };
// void setup() {
// Serial.begin(9600);
// Serial.println(edge4[0].x); // Outputs 46
// Serial.println(wheelAnim.edge4[0].x); // Outputs 0
// }
// void loop() {
// // put your main code here, to run repeatedly:
// }
#include <Arduino.h>
struct Point
{ // Point in 2D space
int16_t x;
int16_t y;
};
struct WheelAnim
{ // Animation steps for revolver cylinder menu
Point* hole1;
Point* hole2;
Point* hole3;
Point* hole4;
Point* hole5;
Point* edge1;
Point* edge2;
Point* edge3;
Point* edge4;
};
// Define the general arrays
Point holeArray[9] = {{-18, 14}, {-16, 17}, {-11, 20}, {-6, 22}, {-20, -11}, {-20, -11}, {-20, -11}, {-20, -11}, {-20, -11}};
Point edgeArray[9] = {{-40, 23}, {-40, 23}, {-40, 23}, {-44, -12}, {-46, 0}, {-44, 12}, {-40, 23}, {-36, 28}, {-30, 35}};
// Initialize the structure with pointers to the desired array elements
WheelAnim wheelAnim = {
&holeArray[4], // Access starting at index 4
&holeArray[4], // Access starting at index 4
&holeArray[4], // Access starting at index 4
&holeArray[4], // Access starting at index 4
&holeArray[4], // Access starting at index 4
&edgeArray[4], // Access starting at index 4
&edgeArray[4], // Access starting at index 4
&edgeArray[4], // Access starting at index 4
&edgeArray[4] // Access starting at index 4
};
void setup() {
Serial.begin(9600);
// Example of accessing elements
Serial.println(wheelAnim.edge4->x); // Outputs the x coordinate of the element at index 4 in edgeArray
Serial.println((wheelAnim.edge4 - 2)->x); // Outputs the x coordinate of the element at index 5 in edgeArray
}
void loop() {
// Your animation code here
}