1 /* 2 * autorotator.h 3 * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath 4 * DIN Is Noise is released under GNU Public License 2.0 5 * For more information, please visit https://dinisnoise.org/ 6 */ 7 8 #ifndef __autorotator 9 #define __autorotator 10 11 #include "autoflip.h" 12 #include "alarm.h" 13 14 struct defvelaccel; 15 16 struct autorotator { 17 18 defvelaccel& dva; 19 20 int yes; 21 22 enum {CLOCKWISE, ANTICLOCKWISE, RANDOM}; 23 int dir; // +1 = anti-clockwise , -1 = clockwise 24 autoflipt autoflip; 25 26 enum {TICK, SMOOTH}; 27 int mov; 28 29 alarm_t tik; 30 float deg; 31 float tps; 32 33 float rpm; 34 35 struct anglett { 36 float persec; 37 float theta; anglettautorotator::anglett38 anglett () { 39 persec = 0.0f; 40 theta = 0.0f; 41 } 42 } angle; 43 44 autorotator (defvelaccel& d); 45 46 void set_rpm (float r); 47 48 void calc (double dt); 49 setdegautorotator50 inline void setdeg (float d) { 51 deg = d; 52 if (deg < 0.0f) deg = 0.0f; 53 extern const float PI_BY_180; 54 angle.persec = deg * PI_BY_180; 55 } 56 settpsautorotator57 inline void settps (float t) { 58 tps = t; 59 if (tps < 1.0) tps = 1.0; 60 tik.triggert = 1.0 / tps; 61 } 62 63 void chgdeg (float dd); 64 void chgtps (float t); 65 66 }; 67 68 std::ostream& operator<< (std::ostream&, autorotator& ar); 69 std::istream& operator>> (std::istream&, autorotator& ar); 70 71 #endif 72