commit 4e5c55e846f3012af2e0009b07f19886ec3abea1 Author: vojta@alfred Date: Sun Feb 1 00:00:07 2026 +0100 Prvni commit. diff --git a/arduino/ruka_lafvin/APP/LAFVIN_Robot_arm_9_4_15.apk b/arduino/ruka_lafvin/APP/LAFVIN_Robot_arm_9_4_15.apk new file mode 100644 index 0000000..088c073 Binary files /dev/null and b/arduino/ruka_lafvin/APP/LAFVIN_Robot_arm_9_4_15.apk differ diff --git a/arduino/ruka_lafvin/Code/Lesson_4_INSTALL/Lesson_4_INSTALL.ino b/arduino/ruka_lafvin/Code/Lesson_4_INSTALL/Lesson_4_INSTALL.ino new file mode 100644 index 0000000..3ae3e1f --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_4_INSTALL/Lesson_4_INSTALL.ino @@ -0,0 +1,26 @@ +#include +Servo myservo1; // create servo object to control a servo +Servo myservo2; +Servo myservo3; +Servo myservo4; +int pos1=90, pos2=90, pos3=90, pos4=90; //define the variable of 4 servo angle and assign the initial value for installing +void setup() +{ + Serial.begin(9600); + myservo1.attach(3); // set the control pin of servo 1 to 3 digital I/0 + myservo2.attach(5); // set the control pin of servo 2 to 5 digital I/0 + myservo3.attach(6); // set the control pin of servo 3 to 6 digital I/0 + myservo4.attach(9); // set the control pin of servo 4 to 9 digital I/0 + delay(1000); +} + +void loop() +{ + myservo1.write(pos1); // Control servo motor rotation to specified angle + myservo2.write(pos2); + myservo3.write(pos3); + myservo4.write(pos4); + delay(1000); + + +} diff --git a/arduino/ruka_lafvin/Code/Lesson_5_Multiple_Servo/Lesson_5_Multiple_Servo.ino b/arduino/ruka_lafvin/Code/Lesson_5_Multiple_Servo/Lesson_5_Multiple_Servo.ino new file mode 100644 index 0000000..5061a4c --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_5_Multiple_Servo/Lesson_5_Multiple_Servo.ino @@ -0,0 +1,110 @@ +#include +Servo myservo1; // create servo object to control a servo +Servo myservo2; +Servo myservo3; +Servo myservo4; +int pos1=90, pos2=90, pos3=90, pos4=90; + +void setup() +{ + myservo1.attach(3); // set the control pin of servo 1 to 3 digital I/0 + myservo2.attach(5); // set the control pin of servo 1 to 3 digital I/0 + myservo3.attach(6); // set the control pin of servo 1 to 3 digital I/0 + myservo4.attach(9); // set the control pin of servo 1 to 3 digital I/0 + + myservo1.write(pos1); + myservo2.write(pos2); + myservo3.write(pos3); + myservo4.write(pos4); + delay(1500); +} + +void loop() +{ + + // close the claw + for(pos4;pos4>45;pos4--) + { + myservo4.write(pos4); + } + delay(1000); + + // open the claw + for(pos4;pos4<120;pos4++) + { + myservo4.write(pos4); + } + delay(1000); + + +// turn right + for(pos1;pos1>30;pos1--) + { + myservo1.write(pos1); + delay(5); // delay 5ms(used to adjust the servo speed) + } + delay(1000); + + + + // turn to left + for(pos1;pos1<150;pos1++) + { + myservo1.write(pos1); + delay(5); + } + delay(1000); + + // stretch out the arm + for(pos2;pos2<130;pos2++) + { + myservo2.write(pos2); + delay(5); + } + delay(1000); + + + // retracte the arm + for(pos2;pos2>80;pos2--) + { + myservo2.write(pos2); + delay(5); + } + delay(1000); + + + + + // raise the arm + for(pos3;pos3<100;pos3++) + { + myservo3.write(pos3); + delay(5); + } + delay(1500); + + // Lower the arm + for(pos3;pos3>40;pos3--) + { + myservo3.write(pos3); + delay(5); + } + delay(1000); + +} + + + + + + + + + + + + + + + + diff --git a/arduino/ruka_lafvin/Code/Lesson_5_Single_Servo/Lesson_5_Single_Servo.ino b/arduino/ruka_lafvin/Code/Lesson_5_Single_Servo/Lesson_5_Single_Servo.ino new file mode 100644 index 0000000..beef46e --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_5_Single_Servo/Lesson_5_Single_Servo.ino @@ -0,0 +1,19 @@ +#include +Servo myservo; // create servo object to control a servo + +void setup() +{ + Serial.begin(9600); + delay(1000); +} + +void loop() +{ + myservo.attach(3); // modify each pin to adjust + //myservo.write(0); // the servo will automatically rotate to 0° + //delay(1000); + myservo.write(90); // the servo will automatically rotate to 90° + //myservo.write(180); // the servo will automatically rotate to 180° + delay(1000); + +} diff --git a/arduino/ruka_lafvin/Code/Lesson_6__Analog_Joystick_Module/Lesson_6__Analog_Joystick_Module.ino b/arduino/ruka_lafvin/Code/Lesson_6__Analog_Joystick_Module/Lesson_6__Analog_Joystick_Module.ino new file mode 100644 index 0000000..6e61fcd --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_6__Analog_Joystick_Module/Lesson_6__Analog_Joystick_Module.ino @@ -0,0 +1,46 @@ +const int right_X = A2; // define the right X pin to A2 +const int right_Y = A5; // define the right Y pin to A5 +const int right_key = 7; //define the right key pin to 7(that is the value Z) + +const int left_X = A3; //define the left X pin to A3 +const int left_Y = A4; // define the left Y pin to A4 +const int left_key = 8; //define the left key pin to 8(that is the value Z) + +void setup() +{ + pinMode(right_key, INPUT); // set the right/left key to INPUT + pinMode(left_key, INPUT); + Serial.begin(9600); // set the baud rate to 9600 +} + +void loop() +{ + int x1,y1,z1; // define the variable, used to save the joystick value it reads + int x2,y2,z2; + + x2 = analogRead(right_X); // read the value of right X + y2 = analogRead(right_Y); // read the value of right Y + z2 = digitalRead(right_key); //// read the value of right Z + + x1 = analogRead(left_X); // read the value of left X + y1 = analogRead(left_Y); // read the value of left Y + z1 = digitalRead(left_key); // read the value of left Z + + Serial.println("#####right_joystick########"); + Serial.print("right_X = "); // on the serial monitor, print out right_X = + Serial.println(x2 ,DEC); // print out the value of right X and line wrap + Serial.print("right_Y = "); + Serial.println(y2 ,DEC); + //Serial.print("right_key = "); + //Serial.println(z2 ,DEC); + Serial.println("##########################"); + Serial.println("#####left_joystick########"); + Serial.print("left_X = "); + Serial.println(x1 ,DEC); + Serial.print("left_Y = "); + Serial.println(y1 ,DEC); + //Serial.print("left_key = "); + //Serial.println(z1 ,DEC); + Serial.println("##########################"); + delay(2000); +} diff --git a/arduino/ruka_lafvin/Code/Lesson_7_Dual_JoyStick_Controlled_Robot_Arm/Lesson_7_Dual_JoyStick_Controlled_Robot_Arm.ino b/arduino/ruka_lafvin/Code/Lesson_7_Dual_JoyStick_Controlled_Robot_Arm/Lesson_7_Dual_JoyStick_Controlled_Robot_Arm.ino new file mode 100644 index 0000000..a1c14e8 --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_7_Dual_JoyStick_Controlled_Robot_Arm/Lesson_7_Dual_JoyStick_Controlled_Robot_Arm.ino @@ -0,0 +1,179 @@ +#include // add the servo libraries +Servo myservo1; // create servo object to control a servo +Servo myservo2; +Servo myservo3; +Servo myservo4; +int pos1=90, pos2=90, pos3=90, pos4=90; // define the variable of 4 servo angle,and assign the initial value (that is the boot posture +//angle value) +const int right_X = A2; // define the right X pin to A2 +const int right_Y = A5; // define the right Y pin to A5 +const int right_key = 7; // define the right key pin to 7(that is the value of Z) +const int left_X = A3; // define the left X pin to A3 +const int left_Y = A4; // define the left X pin to A4 +const int left_key = 8; //define the left key pin to 8(that is the value of Z) +int x1,y1,z1; // define the variable, used to save the joystick value it read. +int x2,y2,z2; + +void setup() +{ +// boot posture +myservo1.write(pos1); +delay(1000); +myservo2.write(pos2); +myservo3.write(pos3); +myservo4.write(pos4); +delay(1500); +pinMode(right_key, INPUT); // set the right/left key to INPUT +pinMode(left_key, INPUT); +Serial.begin(9600); // set the baud rate to 9600 +} +void loop() +{ +myservo1.attach(3); // set the control pin of servo 1 to D3 dizuo-servo1-3 +myservo2.attach(5); // set the control pin of servo 2 to D5 arm-servo2-5 +myservo3.attach(6); //set the control pin of servo 3 to D6 lower arm-servo-6 +myservo4.attach(9); // set the control pin of servo 4 to D9 claw-servo-9 +x2 = analogRead(right_X); //read the right X value +y2 = analogRead(right_Y); // read the right Y value +z2 = digitalRead(right_key); //// read the right Z value +x1 = analogRead(left_X); //read the left X value +y1 = analogRead(left_Y); //read the left Y value +z1 = digitalRead(left_key); // read the left Z value +//delay(5); // lower the speed overall + +// claw +claw(); + +// rotate +turn(); + +// upper arm +upper_arm(); + +//lower arm +lower_arm(); +} + + + +//*************************************************** +//claw +void claw() +{ +//claw +if(x1<50) // if push the left joystick to the right +{ +pos4=pos4+3; +myservo4.write(pos4); //servo 4 operates the motion, the claw gradually opens. +delay(5); + +if(pos4>120) //limit the largest angle when open the claw +{ +pos4=120; +} +} + +if(x1>1000) ////if push the right joystick to the left +{ +pos4=pos4-3; +myservo4.write(pos4); // servo 4 operates the action, claw is gradually closed. +delay(5); +if(pos4<45) // +{ +pos4=45; //limit the largest angle when close the claw +} + +} +} + + + +//******************************************************/ +// turn +void turn() +{ +if(x2<50) //if push the right joystick to the let +{ +pos1=pos1+3; +myservo1.write(pos1); // arm turns left +delay(5); +if(pos1>180) //limit the angle when turn right +{ +pos1=180; +} + +} + +if(x2>1000) // if push the right joystick to the right +{ +pos1=pos1-3; +myservo1.write(pos1); //servo 1 operates the motion, the arm turns right. +delay(5); +if(pos1<1) // limit the angle when turn left +{ +pos1=1; +} +} +} + + + + +//**********************************************************/ +// lower arm +void lower_arm() +{ +if(y2>1000) // if push the right joystick downward +{ +pos2=pos2-2; +myservo2.write(pos2); // lower arm will draw back +delay(5); +if(pos2<25) // limit the retracted angle +{ +pos2=25; +} +} + +if(y2<50) // if push the right joystick upward +{ +pos2=pos2+2; +myservo2.write(pos2); // lower arm will stretch out +delay(5); +if(pos2>180) // limit the stretched angle +{ +pos2=180; +} +} +} + + + + + +//*************************************************************/ + +//upper arm +void upper_arm() +{ +if(y1<50) // if push the left joystick downward +{ +pos3=pos3-2; +myservo3.write(pos3); // upper arm will go down +delay(5); +if(pos3<1) // limit the angle when go down +{ +pos3=1; +} +} +if(y1>1000) // if push the left joystick upward +{ +pos3=pos3+2; +myservo3.write(pos3); // the upper arm will lift +delay(5); + +if(pos3>135) //limit the lifting angle +{ +pos3=135; +} +} +} diff --git a/arduino/ruka_lafvin/Code/Lesson_8_Bluetooth_Controlling_Arm/Lesson_8_Bluetooth_Controlling_Arm.ino b/arduino/ruka_lafvin/Code/Lesson_8_Bluetooth_Controlling_Arm/Lesson_8_Bluetooth_Controlling_Arm.ino new file mode 100644 index 0000000..770482a --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_8_Bluetooth_Controlling_Arm/Lesson_8_Bluetooth_Controlling_Arm.ino @@ -0,0 +1,186 @@ +#include // add the servo libraries +Servo myservo1; // create servo object to control a servo +Servo myservo2; +Servo myservo3; +Servo myservo4; +int pos1=90, pos2=90, pos3=90, pos4=90; // define the variable of 4 servo angle and assign the initial value( that is the boot posture angle value) +char val; +int incomingByte = 0; // Received data byte +String inputString = ""; // Used to store received content +boolean newLineReceived = false; // Previous data end flag +boolean startBit = false; //Acceptance Agreement Start Sign +int num_reveice=0; +void setup() +{ + // boot posture + myservo1.write(pos1); + delay(1000); + myservo2.write(pos2); + myservo3.write(pos3); + myservo4.write(pos4); + delay(1500); + + Serial.begin(9600); // set the baud rate to 9600 +} + +void loop() +{ + myservo1.attach(3); // set the control pin of servo 1 to D3 + myservo2.attach(5); // set the control pin of servo 2 to D5 + myservo3.attach(6); // set the control pin of servo 3 to D6 + myservo4.attach(9); // set the control pin of servo 4 to D9 + +while (Serial.available()) + { + incomingByte = Serial.read(); //One byte by byte, the next sentence is read into a string array to form a completed packet + if (incomingByte == '%') + { + num_reveice = 0; + startBit = true; + } + if (startBit == true) + { + num_reveice++; + inputString += (char) incomingByte; + } + if (startBit == true && incomingByte == '#') + { + newLineReceived = true; + startBit = false; + } + + if(num_reveice >= 20) + { + num_reveice = 0; + startBit = false; + newLineReceived = false; + inputString = ""; + } + } + + + +if(newLineReceived) +{ + switch(inputString[1]) + { + case 'B': T_left(); break; // turn left + case 'C': T_right(); break;//turn right + case 'A': RB(); break;// the lower arm will draw back + case 'D': RF(); break;// the lower arm will stretch out + case '5': ZK(); break;//close the claw + case '6': ZB(); break;//close the claw + case '4': LB(); break;//the upper arm will lift up + case '7': LF(); break;//the upper arm will go down + default:break; + } + + inputString = ""; // clear the string + newLineReceived = false; +} + + + + + + +} +//************************************************** +// turn left +void T_left() +{ + pos1=pos1+8; + myservo1.write(pos1); + delay(5); + if(pos1>180) + { + pos1=180; + } +} +//turn right +void T_right() +{ + pos1=pos1-8; + myservo1.write(pos1); + delay(5); + if(pos1<1) + { + pos1=1; + } +} +//******************************************** +//close the claw + +void ZK() +{ + pos4=pos4-8; + Serial.println(pos4); + myservo4.write(pos4); + delay(5); + if(pos4<45) + { + pos4=45; + } +} +// open the claw +void ZB() +{ + pos4=pos4+8; + Serial.println(pos4); + myservo4.write(pos4); + delay(5); + if(pos4>120) + { + pos4=120; + } +} + +//****************************************** +// the lower arm will stretch out +void RF() +{ + pos2=pos2-8; + myservo2.write(pos2); + delay(5); + if(pos2<25) + { + pos2=25; + } +} +// the lower arm will draw back +void RB() +{ + pos2=pos2+8; + myservo2.write(pos2); + delay(5); + if(pos2>180) + { + pos2=180; + } +} + +//*************************************** +//the upper arm will lift up +void LB() +{ + pos3=pos3+8; + myservo3.write(pos3); + delay(5); + if(pos3>135) + { + pos3=135; + } +} + +//the upper arm will go down + +void LF() +{ + pos3=pos3-8; + myservo3.write(pos3); + delay(5); + if(pos3<0) + { + pos3=0; + } +} diff --git a/arduino/ruka_lafvin/Code/Lesson_8_Buletooth_Test_/Lesson_8_Buletooth_Test_.ino b/arduino/ruka_lafvin/Code/Lesson_8_Buletooth_Test_/Lesson_8_Buletooth_Test_.ino new file mode 100644 index 0000000..6d97ac8 --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_8_Buletooth_Test_/Lesson_8_Buletooth_Test_.ino @@ -0,0 +1,68 @@ +int pos1=90, pos2=90, pos3=90, pos4=90; // define the variable of 4 servo angle and assign the initial value( that is the boot posture angle value) +char val; +int incomingByte = 0; // Received data byte +String inputString = ""; // Used to store received content +boolean newLineReceived = false; // Previous data end flag +boolean startBit = false; //Acceptance Agreement Start Sign +int num_reveice=0; +void setup() +{ + Serial.begin(9600); // set the baud rate to 9600 +} + +void loop() +{ +while (Serial.available()) + { + incomingByte = Serial.read(); //One byte by byte, the next sentence is read into a string array to form a completed packet + if (incomingByte == '%') + { + num_reveice = 0; + startBit = true; + } + if (startBit == true) + { + num_reveice++; + inputString += (char) incomingByte; + } + if (startBit == true && incomingByte == '#') + { + newLineReceived = true; + startBit = false; + } + + if(num_reveice >= 20) + { + num_reveice = 0; + startBit = false; + newLineReceived = false; + inputString = ""; + } + } + +if(newLineReceived) +{ + Serial.println(inputString); + inputString = ""; // clear the string + newLineReceived = false; +} + + + + + + + + + + + + + + + + + + + +} diff --git a/arduino/ruka_lafvin/Code/Lesson_9_PS2_Control_Arm/Lesson_9_PS2_Control_Arm.ino b/arduino/ruka_lafvin/Code/Lesson_9_PS2_Control_Arm/Lesson_9_PS2_Control_Arm.ino new file mode 100644 index 0000000..504b653 --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_9_PS2_Control_Arm/Lesson_9_PS2_Control_Arm.ino @@ -0,0 +1,279 @@ + +#include + +PS2X ps2x; // create PS2 Controller Class + + +//right now, the library does NOT support hot pluggable controllers, meaning +//you must always either restart your Arduino after you connect the controller, +//or call config_gamepad(pins) again after connecting the controller. +int error = 0; +byte vibrate = 0; + +#include // add the servo libraries +Servo myservo1; // create servo object to control a servo +Servo myservo2; +Servo myservo3; +Servo myservo4; + +int pos1=90, pos2=90, pos3=90, pos4=90; // define the variable of 4 servo angle and assign the initial value( that is the boot posture angle value) + +void setup(){ + Serial.begin(57600); + +// boot posture + myservo1.write(pos1); + delay(1000); + myservo2.write(pos2); + myservo3.write(pos3); + myservo4.write(pos4); + delay(1500); + + error = ps2x.config_gamepad(13,11,10,12); //setup GamePad(clock, command, attention, data) pins, check for error + + if(error == 0){ + Serial.println("Found Controller, configured successful"); + Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;"); + Serial.println("holding L1 or R1 will print out the analog stick values."); + Serial.println("Go to www.billporter.info for updates and to report bugs."); + } + + else if(error == 1) + Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"); + + else if(error == 2) + Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips"); + + //Serial.print(ps2x.Analog(1), HEX); + + + ps2x.enableRumble(); //enable rumble vibration motors + ps2x.enablePressures(); //enable reading the pressure values from the buttons. + + + +} + +void loop(){ + /* You must Read Gamepad to get new values + Read GamePad and set vibration values + ps2x.read_gamepad(small motor on/off, larger motor strenght from 0-255) + if you don't enable the rumble, use ps2x.read_gamepad(); with no values + + you should call this at least once a second + */ + + myservo1.attach(3); // set the control pin of servo 1 to A1 + myservo2.attach(5); // set the control pin of servo 2 to A0 + myservo3.attach(6); // set the control pin of servo 3 to D6 + myservo4.attach(9); // set the control pin of servo 4 to D9 + + if(error != 0) + return; + + ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at 'vibrate' speed + + if(ps2x.Button(PSB_START)) //will be TRUE as long as button is pressed + Serial.println("Start is being held"); + if(ps2x.Button(PSB_SELECT)) + Serial.println("Select is being held"); + + + if(ps2x.Button(PSB_PAD_UP)) { //will be TRUE as long as button is pressed + Serial.print("Up held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_UP), DEC); + } + if(ps2x.Button(PSB_PAD_RIGHT)){ + Serial.print("Right held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_RIGHT), DEC); + } + if(ps2x.Button(PSB_PAD_LEFT)){ + Serial.print("LEFT held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_LEFT), DEC); + } + if(ps2x.Button(PSB_PAD_DOWN)){ + Serial.print("DOWN held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_DOWN), DEC); + } + + + vibrate = ps2x.Analog(PSAB_BLUE); //this will set the large motor vibrate speed based on + //how hard you press the blue (X) button + + if (ps2x.NewButtonState()) //will be TRUE if any button changes state (on to off, or off to on) + { + if(ps2x.Button(PSB_R3)) + + Serial.println("R3 pressed"); + + + if(ps2x.Button(PSB_L3)) + Serial.println("L3 pressed"); + + if(ps2x.Button(PSB_L2)) + Serial.println("L2 pressed"); + if(ps2x.Button(PSB_R2)) + Serial.println("R2 pressed"); + if(ps2x.Button(PSB_GREEN)) + Serial.println("Triangle pressed"); + + } + + + if(ps2x.ButtonPressed(PSB_RED)) //will be TRUE if button was JUST pressed + Serial.println("Circle just pressed"); + + if(ps2x.ButtonReleased(PSB_PINK)) //will be TRUE if button was JUST released + Serial.println("Square just released"); + + if(ps2x.NewButtonState(PSB_BLUE)) //will be TRUE if button was JUST pressed OR released + Serial.println("X just changed"); + + // claw +claw(); + +// rotate +turn(); + +// upper arm +upper_arm(); + +//lower arm +lower_arm(); + + if(ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) // print stick values if either is TRUE + { + Serial.print("Stick Values:"); + Serial.print(ps2x.Analog(PSS_LY), DEC); //Left stick, Y axis. Other options: LX, RY, RX + Serial.print(","); + Serial.print(ps2x.Analog(PSS_LX), DEC); + Serial.print(","); + Serial.print(ps2x.Analog(PSS_RY), DEC); + Serial.print(","); + Serial.println(ps2x.Analog(PSS_RX), DEC); + } + delay(5); +} + + + + + +//*************************************************** +//claw +void claw() +{ +//claw +if(ps2x.Analog(PSS_LX)<10) // if push the left joystick to the right +{ +pos4=pos4-3; +myservo4.write(pos4); //servo 4 operates the motion, the claw gradually opens. +delay(5); +if(pos4<45) // limit the largest angle when open the claw + +pos4=45; +} + + +if(ps2x.Analog(PSS_LX)>220) ////if push the right joystick to the left +{ +pos4=pos4+3; +myservo4.write(pos4); // servo 4 operates the action, claw is gradually closed. +delay(5); +if(pos4>120) // limit the largest angle when close the claw +{ +pos4=120; +} +} +} + + + +//******************************************************/ +// turn +void turn() +{ +if(ps2x.Analog (PSS_RX) < 50) //if push the right joystick to the let +{ +pos1=pos1+3; +myservo1.write(pos1); // arm turns left +delay(5); +if(pos1>180) //limit the angle when turn right +{ +pos1=180; +} + +} + +if(ps2x.Analog (PSS_RX) > 200) // if push the right joystick to the right +{ +pos1=pos1-3; +myservo1.write(pos1); //servo 1 operates the motion, the arm turns right. +delay(5); +if(pos1<1) // limit the angle when turn left +{ +pos1=1; +} +} +} + + + + +//**********************************************************/ +// lower arm +void lower_arm() +{ +if(ps2x.Analog(PSS_RY)>200) // if push the right joystick downward +{ +pos2=pos2-2; +myservo2.write(pos2); // lower arm will draw back +delay(5); +if(pos2<25) // limit the retracted angle +{ +pos2=25; +} +} + +if(ps2x.Analog(PSS_RY)<50) // if push the right joystick upward +{ +pos2=pos2+2; +myservo2.write(pos2); // lower arm will stretch out +delay(5); +if(pos2>180) // limit the stretched angle +{ +pos2=180; +} +} +} + + + + + +//*************************************************************/ + +//upper arm +void upper_arm() +{ +if(ps2x.Analog(PSS_LY)<10) // if push the left joystick downward +{ +pos3=pos3+2; +myservo3.write(pos3); // upper arm will go down +delay(5); +if(pos3>135) // limit the angle when go down +{ +pos3=135; +} +} +if(ps2x.Analog(PSS_LY)>200) // if push the left joystick upward +{ +pos3=pos3-2; +myservo3.write(pos3); // the upper arm will lift +delay(5); +if(pos3<1) //limit the lifting angle +{ +pos3=1; +} +} +} diff --git a/arduino/ruka_lafvin/Code/Lesson_9_PS2_Controlling_Posture_Memory/Lesson_9_PS2_Controlling_Posture_Memory.ino b/arduino/ruka_lafvin/Code/Lesson_9_PS2_Controlling_Posture_Memory/Lesson_9_PS2_Controlling_Posture_Memory.ino new file mode 100644 index 0000000..69044b7 --- /dev/null +++ b/arduino/ruka_lafvin/Code/Lesson_9_PS2_Controlling_Posture_Memory/Lesson_9_PS2_Controlling_Posture_Memory.ino @@ -0,0 +1,401 @@ + +#include + +PS2X ps2x; // create PS2 Controller Class + + +//right now, the library does NOT support hot pluggable controllers, meaning +//you must always either restart your Arduino after you connect the controller, +//or call config_gamepad(pins) again after connecting the controller. +int error = 0; +byte vibrate = 0; +int s1,s2,s3,s4; +int jiyi1[20]; // define four array, separately used to save the angle of 4 servos. +int jiyi2[20]; +int jiyi3[20]; +int jiyi4[20]; +int i=0; +int j=0; +#include // add the servo libraries +Servo myservo1; // create servo object to control a servo +Servo myservo2; +Servo myservo3; +Servo myservo4; + +int pos1=90, pos2=90, pos3=90, pos4=90; // define the variable of 4 servo angle and assign the initial value( that is the boot posture angle value) + +void setup(){ + Serial.begin(57600); + +// boot posture + myservo1.write(pos1); + delay(1000); + myservo2.write(pos2); + myservo3.write(pos3); + myservo4.write(pos4); + delay(1500); + + error = ps2x.config_gamepad(13,11,10,12); //setup GamePad(clock, command, attention, data) pins, check for error + + if(error == 0){ + Serial.println("Found Controller, configured successful"); + Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;"); + Serial.println("holding L1 or R1 will print out the analog stick values."); + Serial.println("Go to www.billporter.info for updates and to report bugs."); + } + + else if(error == 1) + Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"); + + else if(error == 2) + Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips"); + + //Serial.print(ps2x.Analog(1), HEX); + + + ps2x.enableRumble(); //enable rumble vibration motors + ps2x.enablePressures(); //enable reading the pressure values from the buttons. + + + +} + +void loop(){ + /* You must Read Gamepad to get new values + Read GamePad and set vibration values + ps2x.read_gamepad(small motor on/off, larger motor strenght from 0-255) + if you don't enable the rumble, use ps2x.read_gamepad(); with no values + + you should call this at least once a second + */ + + myservo1.attach(3); // set the control pin of servo 1 to A1 + myservo2.attach(5); // set the control pin of servo 2 to A0 + myservo3.attach(6); // set the control pin of servo 3 to D6 + myservo4.attach(9); // set the control pin of servo 4 to D9 + + if(error != 0) + return; + + ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at 'vibrate' speed + + if(ps2x.Button(PSB_START)) //will be TRUE as long as button is pressed + Serial.println("Start is being held"); + if(ps2x.Button(PSB_SELECT)) + Serial.println("Select is being held"); + + + if(ps2x.Button(PSB_PAD_UP)) { //will be TRUE as long as button is pressed + Serial.print("Up held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_UP), DEC); + } + if(ps2x.Button(PSB_PAD_RIGHT)){ + Serial.print("Right held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_RIGHT), DEC); + } + if(ps2x.Button(PSB_PAD_LEFT)){ + Serial.print("LEFT held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_LEFT), DEC); + } + if(ps2x.Button(PSB_PAD_DOWN)){ + Serial.print("DOWN held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_DOWN), DEC); + } + + + vibrate = ps2x.Analog(PSAB_BLUE); //this will set the large motor vibrate speed based on + //how hard you press the blue (X) button + if (ps2x.NewButtonState()) //will be TRUE if any button changes state (on to off, or off to on) + { + if(ps2x.Button(PSB_R3)) + { + //Serial.println("R3 pressed"); + // record + s1=myservo1.read(); + delay(100); + Serial.println(s1); + s2=myservo2.read(); + delay(100); + Serial.println(s2); + s3=myservo3.read(); + delay(100); + Serial.println(s3); + s4=myservo4.read(); + delay(100); + Serial.println(s4); + + jiyi1[i]=s1; // save the servo value read in the array sequentially + jiyi2[i]=s2; + jiyi3[i]=s3; + jiyi4[i]=s4; + i++; + j=i; + // delay(100); + Serial.println(i); + } + + if(ps2x.Button(PSB_L3)) + { + //Serial.println("L3 pressed"); + i=0; + //执行 + pos1 = myservo1.read(); + pos2 = myservo2.read(); + pos3 = myservo3.read(); + pos4 = myservo4.read(); + + for(int k=0;kjiyi1[k]) //while loop, make servo turn to the position of value stored in the array. + { + myservo1.write(pos1); // servo 1 executes the action + delay(5); //delay 5ms,controlling the rotating speed of servo + pos1--; + //Serial.println(pos1); + } + +//********************************************** +// the same analysis as the previous servo + if(pos2jiyi2[k]) + { + myservo2.write(pos2); + delay(5); + pos2--; + //Serial.println(pos1); + } + } + //***************************************************** + //the same analysis + if(pos3jiyi3[k]) + { + myservo3.write(pos3); + delay(5); + pos3--; + //Serial.println(pos1); + } + } + //***************************************************** + //the same analysis + if(pos4jiyi4[k]) + { + myservo4.write(pos4); + delay(5); + pos4--; + //Serial.println(pos1); + } + } + } + } + } + + + if(ps2x.Button(PSB_L2)) + Serial.println("L2 pressed"); + if(ps2x.Button(PSB_R2)) + Serial.println("R2 pressed"); + if(ps2x.Button(PSB_GREEN)) + Serial.println("Triangle pressed"); + + } + + + if(ps2x.ButtonPressed(PSB_RED)) //will be TRUE if button was JUST pressed + Serial.println("Circle just pressed"); + + if(ps2x.ButtonReleased(PSB_PINK)) //will be TRUE if button was JUST released + Serial.println("Square just released"); + + if(ps2x.NewButtonState(PSB_BLUE)) //will be TRUE if button was JUST pressed OR released + Serial.println("X just changed"); + + // claw +claw(); + +// rotate +turn(); + +// upper arm +upper_arm(); + +//lower arm +lower_arm(); + + if(ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) // print stick values if either is TRUE + { + Serial.print("Stick Values:"); + Serial.print(ps2x.Analog(PSS_LY), DEC); //Left stick, Y axis. Other options: LX, RY, RX + Serial.print(","); + Serial.print(ps2x.Analog(PSS_LX), DEC); + Serial.print(","); + Serial.print(ps2x.Analog(PSS_RY), DEC); + Serial.print(","); + Serial.println(ps2x.Analog(PSS_RX), DEC); + } + delay(5); +} +//*************************************************** +//claw +void claw() +{ +//claw +if(ps2x.Analog(PSS_LX)<10) // if push the left joystick to the right +{ +pos4=pos4-3; +myservo4.write(pos4); //servo 4 operates the motion, the claw gradually opens. +delay(5); +if(pos4<45) // limit the largest angle when open the claw + +pos4=45; +} + + +if(ps2x.Analog(PSS_LX)>220) ////if push the right joystick to the left +{ +pos4=pos4+3; +myservo4.write(pos4); // servo 4 operates the action, claw is gradually closed. +delay(5); +if(pos4>120) // limit the largest angle when close the claw +{ +pos4=120; +} +} +} + + + +//******************************************************/ +// turn +void turn() +{ +if(ps2x.Analog (PSS_RX) < 50) //if push the right joystick to the let +{ +pos1=pos1+3; +myservo1.write(pos1); // arm turns left +delay(5); +if(pos1>180) //limit the angle when turn right +{ +pos1=180; +} + +} + +if(ps2x.Analog (PSS_RX) > 200) // if push the right joystick to the right +{ +pos1=pos1-3; +myservo1.write(pos1); //servo 1 operates the motion, the arm turns right. +delay(5); +if(pos1<1) // limit the angle when turn left +{ +pos1=1; +} +} +} + + + + +//**********************************************************/ +// lower arm +void lower_arm() +{ +if(ps2x.Analog(PSS_RY)>200) // if push the right joystick downward +{ +pos2=pos2-2; +myservo2.write(pos2); // lower arm will draw back +delay(5); +if(pos2<25) // limit the retracted angle +{ +pos2=25; +} +} + +if(ps2x.Analog(PSS_RY)<50) // if push the right joystick upward +{ +pos2=pos2+2; +myservo2.write(pos2); // lower arm will stretch out +delay(5); +if(pos2>180) // limit the stretched angle +{ +pos2=180; +} +} +} + + + + + +//*************************************************************/ + +//upper arm +void upper_arm() +{ +if(ps2x.Analog(PSS_LY)<10) // if push the left joystick downward +{ +pos3=pos3+2; +myservo3.write(pos3); // upper arm will go down +delay(5); +if(pos3>135) // limit the angle when go down +{ +pos3=135; +} +} +if(ps2x.Analog(PSS_LY)>200) // if push the left joystick upward +{ +pos3=pos3-2; +myservo3.write(pos3); // the upper arm will lift +delay(5); +if(pos3<1) //limit the lifting angle +{ +pos3=1; +} +} +} diff --git a/arduino/ruka_lafvin/Library/PS2X_lib/PS2X_lib.cpp b/arduino/ruka_lafvin/Library/PS2X_lib/PS2X_lib.cpp new file mode 100644 index 0000000..5ef42cc --- /dev/null +++ b/arduino/ruka_lafvin/Library/PS2X_lib/PS2X_lib.cpp @@ -0,0 +1,464 @@ +#include "PS2X_lib.h" +#include +#include +#include +#include +#if ARDUINO > 22 + #include "Arduino.h" +#else + #include "WProgram.h" + #include "pins_arduino.h" +#endif + +static byte enter_config[]={0x01,0x43,0x00,0x01,0x00}; +static byte set_mode[]={0x01,0x44,0x00,0x01,0x03,0x00,0x00,0x00,0x00}; +static byte set_bytes_large[]={0x01,0x4F,0x00,0xFF,0xFF,0x03,0x00,0x00,0x00}; +static byte exit_config[]={0x01,0x43,0x00,0x00,0x5A,0x5A,0x5A,0x5A,0x5A}; +static byte enable_rumble[]={0x01,0x4D,0x00,0x00,0x01}; +static byte type_read[]={0x01,0x45,0x00,0x5A,0x5A,0x5A,0x5A,0x5A,0x5A}; + +/****************************************************************************************/ +boolean PS2X::NewButtonState() { + return ((last_buttons ^ buttons) > 0); +} + +/****************************************************************************************/ +boolean PS2X::NewButtonState(unsigned int button) { + return (((last_buttons ^ buttons) & button) > 0); +} + +/****************************************************************************************/ +boolean PS2X::ButtonPressed(unsigned int button) { + return(NewButtonState(button) & Button(button)); +} + +/****************************************************************************************/ +boolean PS2X::ButtonReleased(unsigned int button) { + return((NewButtonState(button)) & ((~last_buttons & button) > 0)); +} + +/****************************************************************************************/ +boolean PS2X::Button(uint16_t button) { + return ((~buttons & button) > 0); +} + +/****************************************************************************************/ +unsigned int PS2X::ButtonDataByte() { + return (~buttons); +} + +/****************************************************************************************/ +byte PS2X::Analog(byte button) { + return PS2data[button]; +} + +/****************************************************************************************/ +unsigned char PS2X::_gamepad_shiftinout (char byte) { + unsigned char tmp = 0; + for(unsigned char i=0;i<8;i++) { + if(CHK(byte,i)) CMD_SET(); + else CMD_CLR(); + + CLK_CLR(); + delayMicroseconds(CTRL_CLK); + + //if(DAT_CHK()) SET(tmp,i); + if(DAT_CHK()) bitSet(tmp,i); + + CLK_SET(); +#if CTRL_CLK_HIGH + delayMicroseconds(CTRL_CLK_HIGH); +#endif + } + CMD_SET(); + delayMicroseconds(CTRL_BYTE_DELAY); + return tmp; +} + +/****************************************************************************************/ +void PS2X::read_gamepad() { + read_gamepad(false, 0x00); +} + +/****************************************************************************************/ +boolean PS2X::read_gamepad(boolean motor1, byte motor2) { + double temp = millis() - last_read; + + if (temp > 1500) //waited to long + reconfig_gamepad(); + + if(temp < read_delay) //waited too short + delay(read_delay - temp); + + if(motor2 != 0x00) + motor2 = map(motor2,0,255,0x40,0xFF); //noting below 40 will make it spin + + char dword[9] = {0x01,0x42,0,motor1,motor2,0,0,0,0}; + byte dword2[12] = {0,0,0,0,0,0,0,0,0,0,0,0}; + + // Try a few times to get valid data... + for (byte RetryCnt = 0; RetryCnt < 5; RetryCnt++) { + CMD_SET(); + CLK_SET(); + ATT_CLR(); // low enable joystick + + delayMicroseconds(CTRL_BYTE_DELAY); + //Send the command to send button and joystick data; + for (int i = 0; i<9; i++) { + PS2data[i] = _gamepad_shiftinout(dword[i]); + } + + if(PS2data[1] == 0x79) { //if controller is in full data return mode, get the rest of data + for (int i = 0; i<12; i++) { + PS2data[i+9] = _gamepad_shiftinout(dword2[i]); + } + } + + ATT_SET(); // HI disable joystick + // Check to see if we received valid data or not. + // We should be in analog mode for our data to be valid (analog == 0x7_) + if ((PS2data[1] & 0xf0) == 0x70) + break; + + // If we got to here, we are not in analog mode, try to recover... + reconfig_gamepad(); // try to get back into Analog mode. + delay(read_delay); + } + + // If we get here and still not in analog mode (=0x7_), try increasing the read_delay... + if ((PS2data[1] & 0xf0) != 0x70) { + if (read_delay < 10) + read_delay++; // see if this helps out... + } + +#ifdef PS2X_COM_DEBUG + Serial.println("OUT:IN"); + for(int i=0; i<9; i++){ + Serial.print(dword[i], HEX); + Serial.print(":"); + Serial.print(PS2data[i], HEX); + Serial.print(" "); + } + for (int i = 0; i<12; i++) { + Serial.print(dword2[i], HEX); + Serial.print(":"); + Serial.print(PS2data[i+9], HEX); + Serial.print(" "); + } + Serial.println(""); +#endif + + last_buttons = buttons; //store the previous buttons states + +#if defined(__AVR__) + buttons = *(uint16_t*)(PS2data+3); //store as one value for multiple functions +#else + buttons = (uint16_t)(PS2data[4] << 8) + PS2data[3]; //store as one value for multiple functions +#endif + last_read = millis(); + return ((PS2data[1] & 0xf0) == 0x70); // 1 = OK = analog mode - 0 = NOK +} + +/****************************************************************************************/ +byte PS2X::config_gamepad(uint8_t clk, uint8_t cmd, uint8_t att, uint8_t dat) { + return config_gamepad(clk, cmd, att, dat, false, false); +} + +/****************************************************************************************/ +byte PS2X::config_gamepad(uint8_t clk, uint8_t cmd, uint8_t att, uint8_t dat, bool pressures, bool rumble) { + + byte temp[sizeof(type_read)]; + +#ifdef __AVR__ + _clk_mask = digitalPinToBitMask(clk); + _clk_oreg = portOutputRegister(digitalPinToPort(clk)); + _cmd_mask = digitalPinToBitMask(cmd); + _cmd_oreg = portOutputRegister(digitalPinToPort(cmd)); + _att_mask = digitalPinToBitMask(att); + _att_oreg = portOutputRegister(digitalPinToPort(att)); + _dat_mask = digitalPinToBitMask(dat); + _dat_ireg = portInputRegister(digitalPinToPort(dat)); +#else + uint32_t lport; // Port number for this pin + _clk_mask = digitalPinToBitMask(clk); + lport = digitalPinToPort(clk); + _clk_lport_set = portOutputRegister(lport) + 2; + _clk_lport_clr = portOutputRegister(lport) + 1; + + _cmd_mask = digitalPinToBitMask(cmd); + lport = digitalPinToPort(cmd); + _cmd_lport_set = portOutputRegister(lport) + 2; + _cmd_lport_clr = portOutputRegister(lport) + 1; + + _att_mask = digitalPinToBitMask(att); + lport = digitalPinToPort(att); + _att_lport_set = portOutputRegister(lport) + 2; + _att_lport_clr = portOutputRegister(lport) + 1; + + _dat_mask = digitalPinToBitMask(dat); + _dat_lport = portInputRegister(digitalPinToPort(dat)); +#endif + + pinMode(clk, OUTPUT); //configure ports + pinMode(att, OUTPUT); + pinMode(cmd, OUTPUT); + pinMode(dat, INPUT); + +#if defined(__AVR__) + digitalWrite(dat, HIGH); //enable pull-up +#endif + + CMD_SET(); // SET(*_cmd_oreg,_cmd_mask); + CLK_SET(); + + //new error checking. First, read gamepad a few times to see if it's talking + read_gamepad(); + read_gamepad(); + + //see if it talked - see if mode came back. + //If still anything but 41, 73 or 79, then it's not talking + if(PS2data[1] != 0x41 && PS2data[1] != 0x73 && PS2data[1] != 0x79){ +#ifdef PS2X_DEBUG + Serial.println("Controller mode not matched or no controller found"); + Serial.print("Expected 0x41, 0x73 or 0x79, but got "); + Serial.println(PS2data[1], HEX); +#endif + return 1; //return error code 1 + } + + //try setting mode, increasing delays if need be. + read_delay = 1; + + for(int y = 0; y <= 10; y++) { + sendCommandString(enter_config, sizeof(enter_config)); //start config run + + //read type + delayMicroseconds(CTRL_BYTE_DELAY); + + CMD_SET(); + CLK_SET(); + ATT_CLR(); // low enable joystick + + delayMicroseconds(CTRL_BYTE_DELAY); + + for (int i = 0; i<9; i++) { + temp[i] = _gamepad_shiftinout(type_read[i]); + } + + ATT_SET(); // HI disable joystick + + controller_type = temp[3]; + + sendCommandString(set_mode, sizeof(set_mode)); + if(rumble){ sendCommandString(enable_rumble, sizeof(enable_rumble)); en_Rumble = true; } + if(pressures){ sendCommandString(set_bytes_large, sizeof(set_bytes_large)); en_Pressures = true; } + sendCommandString(exit_config, sizeof(exit_config)); + + read_gamepad(); + + if(pressures){ + if(PS2data[1] == 0x79) + break; + if(PS2data[1] == 0x73) + return 3; + } + + if(PS2data[1] == 0x73) + break; + + if(y == 10){ +#ifdef PS2X_DEBUG + Serial.println("Controller not accepting commands"); + Serial.print("mode stil set at"); + Serial.println(PS2data[1], HEX); +#endif + return 2; //exit function with error + } + read_delay += 1; //add 1ms to read_delay + } + return 0; //no error if here +} + +/****************************************************************************************/ +void PS2X::sendCommandString(byte string[], byte len) { +#ifdef PS2X_COM_DEBUG + byte temp[len]; + ATT_CLR(); // low enable joystick + delayMicroseconds(CTRL_BYTE_DELAY); + + for (int y=0; y < len; y++) + temp[y] = _gamepad_shiftinout(string[y]); + + ATT_SET(); //high disable joystick + delay(read_delay); //wait a few + + Serial.println("OUT:IN Configure"); + for(int i=0; i +* +******************************************************************/ + +// $$$$$$$$$$$$ DEBUG ENABLE SECTION $$$$$$$$$$$$$$$$ +// to debug ps2 controller, uncomment these two lines to print out debug to uart +//#define PS2X_DEBUG +//#define PS2X_COM_DEBUG + +#ifndef PS2X_lib_h + #define PS2X_lib_h + +#if ARDUINO > 22 + #include "Arduino.h" +#else + #include "WProgram.h" +#endif + +#include +#include +#include +#ifdef __AVR__ + // AVR + #include + #define CTRL_CLK 4 + #define CTRL_BYTE_DELAY 3 +#else + // Pic32... + #include + #define CTRL_CLK 5 + #define CTRL_CLK_HIGH 5 + #define CTRL_BYTE_DELAY 4 +#endif + +//These are our button constants +#define PSB_SELECT 0x0001 +#define PSB_L3 0x0002 +#define PSB_R3 0x0004 +#define PSB_START 0x0008 +#define PSB_PAD_UP 0x0010 +#define PSB_PAD_RIGHT 0x0020 +#define PSB_PAD_DOWN 0x0040 +#define PSB_PAD_LEFT 0x0080 +#define PSB_L2 0x0100 +#define PSB_R2 0x0200 +#define PSB_L1 0x0400 +#define PSB_R1 0x0800 +#define PSB_GREEN 0x1000 +#define PSB_RED 0x2000 +#define PSB_BLUE 0x4000 +#define PSB_PINK 0x8000 +#define PSB_TRIANGLE 0x1000 +#define PSB_CIRCLE 0x2000 +#define PSB_CROSS 0x4000 +#define PSB_SQUARE 0x8000 + +//Guitar button constants +#define UP_STRUM 0x0010 +#define DOWN_STRUM 0x0040 +#define STAR_POWER 0x0100 +#define GREEN_FRET 0x0200 +#define YELLOW_FRET 0x1000 +#define RED_FRET 0x2000 +#define BLUE_FRET 0x4000 +#define ORANGE_FRET 0x8000 +#define WHAMMY_BAR 8 + +//These are stick values +#define PSS_RX 5 +#define PSS_RY 6 +#define PSS_LX 7 +#define PSS_LY 8 + +//These are analog buttons +#define PSAB_PAD_RIGHT 9 +#define PSAB_PAD_UP 11 +#define PSAB_PAD_DOWN 12 +#define PSAB_PAD_LEFT 10 +#define PSAB_L2 19 +#define PSAB_R2 20 +#define PSAB_L1 17 +#define PSAB_R1 18 +#define PSAB_GREEN 13 +#define PSAB_RED 14 +#define PSAB_BLUE 15 +#define PSAB_PINK 16 +#define PSAB_TRIANGLE 13 +#define PSAB_CIRCLE 14 +#define PSAB_CROSS 15 +#define PSAB_SQUARE 16 + +#define SET(x,y) (x|=(1< + +PS2X ps2x; // create PS2 Controller Class + +int error = 0; +byte type = 0; +const int ledPin = 11; // Mouse control LED (11 on Teensy 2.0, 13 on Arduino Leonardo) + +// parameters for reading the joystick: +int range = 12; // output range of X or Y movement +int responseDelay = 5; // response delay of the mouse, in ms +int threshold = range/4; // resting threshold +int center = range/2; // resting position value + +boolean mouseIsActive = false; // whether or not to control the mouse +int lastSwitchState = LOW; // previous switch state + +void setup(){ + Serial.begin(57600); + + error = ps2x.config_gamepad(15,14,13,12, true, true); //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error + + if(error == 0){ + Serial.println("Found Controller, configured successful"); + } + + else if(error == 1) + Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"); + + else if(error == 2) + Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips"); + + else if(error == 3) + Serial.println("Controller refusing to enter Pressures mode, may not support it. "); + + type = ps2x.readType(); + switch(type) { + case 0: + Serial.println("Unknown Controller type"); + break; + case 1: + Serial.println("DualShock Controller Found"); + break; + case 2: + Serial.println("GuitarHero Controller Found"); + break; + } + + // take control of the mouse: + Mouse.begin(); + Keyboard.begin(); +} + +void loop() +{ + + if(error == 1) //skip loop if no controller found + return; + + ps2x.read_gamepad(false, 0); //read controller and set large motor to spin at 'vibrate' speed + + // read the switch: + int switchState = ps2x.ButtonPressed(PSB_RED); + // if it's changed and it's high, toggle the mouse state: + if (switchState != lastSwitchState) { + if (switchState == HIGH) { + mouseIsActive = !mouseIsActive; + // turn on LED to indicate mouse state: + digitalWrite(ledPin, mouseIsActive); + } + } + // save switch state for next comparison: + lastSwitchState = switchState; + + // read and scale the two axes: + int xReading = readAxis(PSS_LX); + int yReading = readAxis(PSS_LY); + + // if the mouse control state is active, move the mouse: + if (mouseIsActive) { + Mouse.move(xReading, yReading, 0); + } + + // read the mouse button and click or not click: + // if the mouse button is pressed: + if (ps2x.ButtonPressed(PSB_BLUE)) { + // if the mouse is not pressed, press it: + if (!Mouse.isPressed(MOUSE_LEFT)) { + Mouse.press(MOUSE_LEFT); + } + } + // else the mouse button is not pressed: + else { + // if the mouse is pressed, release it: + if (Mouse.isPressed(MOUSE_LEFT)) { + Mouse.release(MOUSE_LEFT); + } + } + + if (ps2x.Button(PSB_PAD_UP)) { + Keyboard.press(KEY_UP_ARROW); + } else { + Keyboard.release(KEY_UP_ARROW); + } + + if (ps2x.Button(PSB_PAD_DOWN)) { + Keyboard.press(KEY_DOWN_ARROW); + } else { + Keyboard.release(KEY_DOWN_ARROW); + } + + if (ps2x.Button(PSB_PAD_RIGHT)) { + Keyboard.press(KEY_RIGHT_ARROW); + } else { + Keyboard.release(KEY_RIGHT_ARROW); + } + + if (ps2x.Button(PSB_PAD_LEFT)) { + Keyboard.press(KEY_LEFT_ARROW); + } else { + Keyboard.release(KEY_LEFT_ARROW); + } + + delay(5); + +} + +/* + reads an axis (0 or 1 for x or y) and scales the + analog input range to a range from 0 to + */ + +int readAxis(int thisAxis) { + // read the analog input: + int reading = ps2x.Analog(thisAxis); + + // map the reading from the analog input range to the output range: + reading = map(reading, 0, 255, 0, range); + + // if the output reading is outside from the + // rest position threshold, use it: + int distance = reading - center; + + if (abs(distance) < threshold) { + distance = 0; + } + + // return the distance for this axis: + return distance; +} diff --git a/arduino/ruka_lafvin/Library/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino b/arduino/ruka_lafvin/Library/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino new file mode 100644 index 0000000..f1c64c8 --- /dev/null +++ b/arduino/ruka_lafvin/Library/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino @@ -0,0 +1,189 @@ +#include //for v1.6 + +/****************************************************************** + * set pins connected to PS2 controller: + * - 1e column: original + * - 2e colmun: Stef? + * replace pin numbers by the ones you use + ******************************************************************/ +#define PS2_DAT 13 //14 +#define PS2_CMD 11 //15 +#define PS2_SEL 10 //16 +#define PS2_CLK 12 //17 + +/****************************************************************** + * select modes of PS2 controller: + * - pressures = analog reading of push-butttons + * - rumble = motor rumbling + * uncomment 1 of the lines for each mode selection + ******************************************************************/ +//#define pressures true +#define pressures false +//#define rumble true +#define rumble false + +PS2X ps2x; // create PS2 Controller Class + +//right now, the library does NOT support hot pluggable controllers, meaning +//you must always either restart your Arduino after you connect the controller, +//or call config_gamepad(pins) again after connecting the controller. + +int error = 0; +byte type = 0; +byte vibrate = 0; + +void setup(){ + + Serial.begin(57600); + + delay(300); //added delay to give wireless ps2 module some time to startup, before configuring it + + //CHANGES for v1.6 HERE!!! **************PAY ATTENTION************* + + //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error + error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, pressures, rumble); + + if(error == 0){ + Serial.print("Found Controller, configured successful "); + Serial.print("pressures = "); + if (pressures) + Serial.println("true "); + else + Serial.println("false"); + Serial.print("rumble = "); + if (rumble) + Serial.println("true)"); + else + Serial.println("false"); + Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;"); + Serial.println("holding L1 or R1 will print out the analog stick values."); + Serial.println("Note: Go to www.billporter.info for updates and to report bugs."); + } + else if(error == 1) + Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"); + + else if(error == 2) + Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips"); + + else if(error == 3) + Serial.println("Controller refusing to enter Pressures mode, may not support it. "); + +// Serial.print(ps2x.Analog(1), HEX); + + type = ps2x.readType(); + switch(type) { + case 0: + Serial.print("Unknown Controller type found "); + break; + case 1: + Serial.print("DualShock Controller found "); + break; + case 2: + Serial.print("GuitarHero Controller found "); + break; + case 3: + Serial.print("Wireless Sony DualShock Controller found "); + break; + } +} + +void loop() { + /* You must Read Gamepad to get new values and set vibration values + ps2x.read_gamepad(small motor on/off, larger motor strenght from 0-255) + if you don't enable the rumble, use ps2x.read_gamepad(); with no values + You should call this at least once a second + */ + if(error == 1) //skip loop if no controller found + return; + + if(type == 2){ //Guitar Hero Controller + ps2x.read_gamepad(); //read controller + + if(ps2x.ButtonPressed(GREEN_FRET)) + Serial.println("Green Fret Pressed"); + if(ps2x.ButtonPressed(RED_FRET)) + Serial.println("Red Fret Pressed"); + if(ps2x.ButtonPressed(YELLOW_FRET)) + Serial.println("Yellow Fret Pressed"); + if(ps2x.ButtonPressed(BLUE_FRET)) + Serial.println("Blue Fret Pressed"); + if(ps2x.ButtonPressed(ORANGE_FRET)) + Serial.println("Orange Fret Pressed"); + + if(ps2x.ButtonPressed(STAR_POWER)) + Serial.println("Star Power Command"); + + if(ps2x.Button(UP_STRUM)) //will be TRUE as long as button is pressed + Serial.println("Up Strum"); + if(ps2x.Button(DOWN_STRUM)) + Serial.println("DOWN Strum"); + + if(ps2x.Button(PSB_START)) //will be TRUE as long as button is pressed + Serial.println("Start is being held"); + if(ps2x.Button(PSB_SELECT)) + Serial.println("Select is being held"); + + if(ps2x.Button(ORANGE_FRET)) { // print stick value IF TRUE + Serial.print("Wammy Bar Position:"); + Serial.println(ps2x.Analog(WHAMMY_BAR), DEC); + } + } + else { //DualShock Controller + ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at 'vibrate' speed + + if(ps2x.Button(PSB_START)) //will be TRUE as long as button is pressed + Serial.println("Start is being held"); + if(ps2x.Button(PSB_SELECT)) + Serial.println("Select is being held"); + + if(ps2x.Button(PSB_PAD_UP)) { //will be TRUE as long as button is pressed + Serial.print("Up held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_UP), DEC); + } + if(ps2x.Button(PSB_PAD_RIGHT)){ + Serial.print("Right held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_RIGHT), DEC); + } + if(ps2x.Button(PSB_PAD_LEFT)){ + Serial.print("LEFT held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_LEFT), DEC); + } + if(ps2x.Button(PSB_PAD_DOWN)){ + Serial.print("DOWN held this hard: "); + Serial.println(ps2x.Analog(PSAB_PAD_DOWN), DEC); + } + + vibrate = ps2x.Analog(PSAB_CROSS); //this will set the large motor vibrate speed based on how hard you press the blue (X) button + if (ps2x.NewButtonState()) { //will be TRUE if any button changes state (on to off, or off to on) + if(ps2x.Button(PSB_L3)) + Serial.println("L3 pressed"); + if(ps2x.Button(PSB_R3)) + Serial.println("R3 pressed"); + if(ps2x.Button(PSB_L2)) + Serial.println("L2 pressed"); + if(ps2x.Button(PSB_R2)) + Serial.println("R2 pressed"); + if(ps2x.Button(PSB_TRIANGLE)) + Serial.println("Triangle pressed"); + } + + if(ps2x.ButtonPressed(PSB_CIRCLE)) //will be TRUE if button was JUST pressed + Serial.println("Circle just pressed"); + if(ps2x.NewButtonState(PSB_CROSS)) //will be TRUE if button was JUST pressed OR released + Serial.println("X just changed"); + if(ps2x.ButtonReleased(PSB_SQUARE)) //will be TRUE if button was JUST released + Serial.println("Square just released"); + + if(ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) { //print stick values if either is TRUE + Serial.print("Stick Values:"); + Serial.print(ps2x.Analog(PSS_LY), DEC); //Left stick, Y axis. Other options: LX, RY, RX + Serial.print(","); + Serial.print(ps2x.Analog(PSS_LX), DEC); + Serial.print(","); + Serial.print(ps2x.Analog(PSS_RY), DEC); + Serial.print(","); + Serial.println(ps2x.Analog(PSS_RX), DEC); + } + } + delay(50); +} diff --git a/arduino/ruka_lafvin/Library/PS2X_lib/keywords.txt b/arduino/ruka_lafvin/Library/PS2X_lib/keywords.txt new file mode 100644 index 0000000..ec68dfa --- /dev/null +++ b/arduino/ruka_lafvin/Library/PS2X_lib/keywords.txt @@ -0,0 +1,78 @@ +####################################### +# Syntax Coloring Map PS2X +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +PS2X KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +Button KEYWORD2 +ButtonDataByte KEYWORD2 +NewButtonState KEYWORD2 +ButtonPressed KEYWORD2 +ButtonReleased KEYWORD2 +read_gamepad KEYWORD2 +config_gamepad KEYWORD2 +enableRumble KEYWORD2 +enablePressures KEYWORD2 +Analog KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### +PSB_SELECT LITERAL1 +PSB_L3 LITERAL1 +PSB_R3 LITERAL1 +PSB_START LITERAL1 +PSB_PAD_UP LITERAL1 +PSB_PAD_RIGHT LITERAL1 +PSB_PAD_DOWN LITERAL1 +PSB_PAD_LEFT LITERAL1 +PSB_L2 LITERAL1 +PSB_R2 LITERAL1 +PSB_L1 LITERAL1 +PSB_R1 LITERAL1 +PSB_GREEN LITERAL1 +PSB_RED LITERAL1 +PSB_BLUE LITERAL1 +PSB_PINK LITERAL1 +PSB_TRIANGLE LITERAL1 +PSB_CIRCLE LITERAL1 +PSB_CROSS LITERAL1 +PSB_SQUARE LITERAL1 +PSS_RX LITERAL1 +PSS_RY LITERAL1 +PSS_LX LITERAL1 +PSS_LY LITERAL1 + +PSAB_PAD_RIGHT LITERAL1 +PSAB_PAD_UP LITERAL1 +PSAB_PAD_DOWN LITERAL1 +PSAB_PAD_LEFT LITERAL1 +PSAB_L2 LITERAL1 +PSAB_R2 LITERAL1 +PSAB_L1 LITERAL1 +PSAB_R1 LITERAL1 +PSAB_GREEN LITERAL1 +PSAB_RED LITERAL1 +PSAB_BLUE LITERAL1 +PSAB_PINK LITERAL1 +PSAB_TRIANGLE LITERAL1 +PSAB_CIRCLE LITERAL1 +PSAB_CROSS LITERAL1 +PSAB_SQUARE LITERAL1 + +GREEN_FRET LITERAL1 +RED_FRET LITERAL1 +YELLOW_FRET LITERAL1 +BLUE_FRET LITERAL1 +ORANGE_FRET LITERAL1 +STAR_POWER LITERAL1 +UP_STRUM LITERAL1 +DOWN_STRUM LITERAL1 +WHAMMY_BAR LITERAL1 diff --git a/arduino/ruka_lafvin/Library/Servo/examples/Knob/Knob.ino b/arduino/ruka_lafvin/Library/Servo/examples/Knob/Knob.ino new file mode 100644 index 0000000..06c252c --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/examples/Knob/Knob.ino @@ -0,0 +1,29 @@ +/* + Controlling a servo position using a potentiometer (variable resistor) + by Michal Rinott + + modified on 8 Nov 2013 + by Scott Fitzgerald + http://arduino.cc/en/Tutorial/Knob +*/ + +#include + +Servo myservo; // create servo object to control a servo + +int potpin = 0; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() +{ + myservo.attach(9); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) + val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180) + myservo.write(val); // sets the servo position according to the scaled value + delay(15); // waits for the servo to get there +} + diff --git a/arduino/ruka_lafvin/Library/Servo/examples/Sweep/Sweep.ino b/arduino/ruka_lafvin/Library/Servo/examples/Sweep/Sweep.ino new file mode 100644 index 0000000..bbe6ea9 --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/examples/Sweep/Sweep.ino @@ -0,0 +1,35 @@ +/* Sweep + by BARRAGAN + This example code is in the public domain. + + modified 8 Nov 2013 + by Scott Fitzgerald + http://arduino.cc/en/Tutorial/Sweep +*/ + +#include + +Servo myservo; // create servo object to control a servo + // twelve servo objects can be created on most boards + +int pos = 0; // variable to store the servo position + +void setup() +{ + myservo.attach(9); // attaches the servo on pin 9 to the servo object +} + +void loop() +{ + for(pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees + { // in steps of 1 degree + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(15); // waits 15ms for the servo to reach the position + } + for(pos = 180; pos>=0; pos-=1) // goes from 180 degrees to 0 degrees + { + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(15); // waits 15ms for the servo to reach the position + } +} + diff --git a/arduino/ruka_lafvin/Library/Servo/keywords(1).txt b/arduino/ruka_lafvin/Library/Servo/keywords(1).txt new file mode 100644 index 0000000..ca5ba79 --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/keywords(1).txt @@ -0,0 +1,24 @@ +####################################### +# Syntax Coloring Map Servo +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +Servo KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +attach KEYWORD2 +detach KEYWORD2 +write KEYWORD2 +read KEYWORD2 +attached KEYWORD2 +writeMicroseconds KEYWORD2 +readMicroseconds KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### diff --git a/arduino/ruka_lafvin/Library/Servo/keywords.txt b/arduino/ruka_lafvin/Library/Servo/keywords.txt new file mode 100644 index 0000000..ca5ba79 --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/keywords.txt @@ -0,0 +1,24 @@ +####################################### +# Syntax Coloring Map Servo +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +Servo KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +attach KEYWORD2 +detach KEYWORD2 +write KEYWORD2 +read KEYWORD2 +attached KEYWORD2 +writeMicroseconds KEYWORD2 +readMicroseconds KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### diff --git a/arduino/ruka_lafvin/Library/Servo/library.properties b/arduino/ruka_lafvin/Library/Servo/library.properties new file mode 100644 index 0000000..b28a1f9 --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/library.properties @@ -0,0 +1,8 @@ +name=Servo +version=1.0 +author=Michael Margolis, Arduino +maintainer=Arduino +sentence=Controls a lot of Servos. +paragraph=This library can control a great number of servos.
It makes careful use of timers: the library can control 12 servos using only 1 timer.
On the Arduino Due you can control up to 60 servos.
+url=http://arduino.cc/en/Reference/Servo +architectures=avr,sam diff --git a/arduino/ruka_lafvin/Library/Servo/library.properties(1) b/arduino/ruka_lafvin/Library/Servo/library.properties(1) new file mode 100644 index 0000000..b28a1f9 --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/library.properties(1) @@ -0,0 +1,8 @@ +name=Servo +version=1.0 +author=Michael Margolis, Arduino +maintainer=Arduino +sentence=Controls a lot of Servos. +paragraph=This library can control a great number of servos.
It makes careful use of timers: the library can control 12 servos using only 1 timer.
On the Arduino Due you can control up to 60 servos.
+url=http://arduino.cc/en/Reference/Servo +architectures=avr,sam diff --git a/arduino/ruka_lafvin/Library/Servo/src/Servo.h b/arduino/ruka_lafvin/Library/Servo/src/Servo.h new file mode 100644 index 0000000..0a04913 --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/src/Servo.h @@ -0,0 +1,110 @@ +/* + Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + Copyright (c) 2009 Michael Margolis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* + A servo is activated by creating an instance of the Servo class passing + the desired pin to the attach() method. + The servos are pulsed in the background using the value most recently + written using the write() method. + + Note that analogWrite of PWM on pins associated with the timer are + disabled when the first servo is attached. + Timers are seized as needed in groups of 12 servos - 24 servos use two + timers, 48 servos will use four. + The sequence used to sieze timers is defined in timers.h + + The methods are: + + Servo - Class for manipulating servo motors connected to Arduino pins. + + attach(pin ) - Attaches a servo motor to an i/o pin. + attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds + default min is 544, max is 2400 + + write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) + writeMicroseconds() - Sets the servo pulse width in microseconds + read() - Gets the last written servo pulse width as an angle between 0 and 180. + readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) + attached() - Returns true if there is a servo attached. + detach() - Stops an attached servos from pulsing its i/o pin. + */ + +#ifndef Servo_h +#define Servo_h + +#include + +/* + * Defines for 16 bit timers used with Servo library + * + * If _useTimerX is defined then TimerX is a 16 bit timer on the current board + * timer16_Sequence_t enumerates the sequence that the timers should be allocated + * _Nbr_16timers indicates how many 16 bit timers are available. + */ + +// Architecture specific include +#if defined(ARDUINO_ARCH_AVR) +#include "avr/ServoTimers.h" +#elif defined(ARDUINO_ARCH_SAM) +#include "sam/ServoTimers.h" +#else +#error "This library only supports boards with an AVR or SAM processor." +#endif + +#define Servo_VERSION 2 // software version of this library + +#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo +#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo +#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached +#define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds + +#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer +#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) + +#define INVALID_SERVO 255 // flag indicating an invalid servo index + +typedef struct { + uint8_t nbr :6 ; // a pin number from 0 to 63 + uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false +} ServoPin_t ; + +typedef struct { + ServoPin_t Pin; + volatile unsigned int ticks; +} servo_t; + +class Servo +{ +public: + Servo(); + uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure + uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes. + void detach(); + void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds + void writeMicroseconds(int value); // Write pulse width in microseconds + int read(); // returns current pulse width as an angle between 0 and 180 degrees + int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) + bool attached(); // return true if this servo is attached, otherwise false +private: + uint8_t servoIndex; // index into the channel data for this servo + int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH + int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH +}; + +#endif diff --git a/arduino/ruka_lafvin/Library/Servo/src/avr/Servo.cpp b/arduino/ruka_lafvin/Library/Servo/src/avr/Servo.cpp new file mode 100644 index 0000000..7fdd9d5 --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/src/avr/Servo.cpp @@ -0,0 +1,317 @@ +/* + Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + Copyright (c) 2009 Michael Margolis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if defined(ARDUINO_ARCH_AVR) + +#include +#include + +#include "Servo.h" + +#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 +#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds + + +#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 + +//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER) + +static servo_t servos[MAX_SERVOS]; // static array of servo structures +static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) + +uint8_t ServoCount = 0; // the total number of attached servos + + +// convenience macros +#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo +#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer +#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel +#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel + +#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo +#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo + +/************ static functions common to all instances ***********************/ + +static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA) +{ + if( Channel[timer] < 0 ) + *TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer + else{ + if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true ) + digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated + } + + Channel[timer]++; // increment to the next channel + if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { + *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks; + if(SERVO(timer,Channel[timer]).Pin.isActive == true) // check if activated + digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high + } + else { + // finished all channels so wait for the refresh period to expire before starting over + if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) ) // allow a few ticks to ensure the next OCR1A not missed + *OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL); + else + *OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed + Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel + } +} + +#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform +// Interrupt handlers for Arduino +#if defined(_useTimer1) +SIGNAL (TIMER1_COMPA_vect) +{ + handle_interrupts(_timer1, &TCNT1, &OCR1A); +} +#endif + +#if defined(_useTimer3) +SIGNAL (TIMER3_COMPA_vect) +{ + handle_interrupts(_timer3, &TCNT3, &OCR3A); +} +#endif + +#if defined(_useTimer4) +SIGNAL (TIMER4_COMPA_vect) +{ + handle_interrupts(_timer4, &TCNT4, &OCR4A); +} +#endif + +#if defined(_useTimer5) +SIGNAL (TIMER5_COMPA_vect) +{ + handle_interrupts(_timer5, &TCNT5, &OCR5A); +} +#endif + +#elif defined WIRING +// Interrupt handlers for Wiring +#if defined(_useTimer1) +void Timer1Service() +{ + handle_interrupts(_timer1, &TCNT1, &OCR1A); +} +#endif +#if defined(_useTimer3) +void Timer3Service() +{ + handle_interrupts(_timer3, &TCNT3, &OCR3A); +} +#endif +#endif + + +static void initISR(timer16_Sequence_t timer) +{ +#if defined (_useTimer1) + if(timer == _timer1) { + TCCR1A = 0; // normal counting mode + TCCR1B = _BV(CS11); // set prescaler of 8 + TCNT1 = 0; // clear the timer count +#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__) + TIFR |= _BV(OCF1A); // clear any pending interrupts; + TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt +#else + // here if not ATmega8 or ATmega128 + TIFR1 |= _BV(OCF1A); // clear any pending interrupts; + TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt +#endif +#if defined(WIRING) + timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); +#endif + } +#endif + +#if defined (_useTimer3) + if(timer == _timer3) { + TCCR3A = 0; // normal counting mode + TCCR3B = _BV(CS31); // set prescaler of 8 + TCNT3 = 0; // clear the timer count +#if defined(__AVR_ATmega128__) + TIFR |= _BV(OCF3A); // clear any pending interrupts; + ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt +#else + TIFR3 = _BV(OCF3A); // clear any pending interrupts; + TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt +#endif +#if defined(WIRING) + timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only +#endif + } +#endif + +#if defined (_useTimer4) + if(timer == _timer4) { + TCCR4A = 0; // normal counting mode + TCCR4B = _BV(CS41); // set prescaler of 8 + TCNT4 = 0; // clear the timer count + TIFR4 = _BV(OCF4A); // clear any pending interrupts; + TIMSK4 = _BV(OCIE4A) ; // enable the output compare interrupt + } +#endif + +#if defined (_useTimer5) + if(timer == _timer5) { + TCCR5A = 0; // normal counting mode + TCCR5B = _BV(CS51); // set prescaler of 8 + TCNT5 = 0; // clear the timer count + TIFR5 = _BV(OCF5A); // clear any pending interrupts; + TIMSK5 = _BV(OCIE5A) ; // enable the output compare interrupt + } +#endif +} + +static void finISR(timer16_Sequence_t timer) +{ + //disable use of the given timer +#if defined WIRING // Wiring + if(timer == _timer1) { + #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) + TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt + #else + TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt + #endif + timerDetach(TIMER1OUTCOMPAREA_INT); + } + else if(timer == _timer3) { + #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) + TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt + #else + ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt + #endif + timerDetach(TIMER3OUTCOMPAREA_INT); + } +#else + //For arduino - in future: call here to a currently undefined function to reset the timer +#endif +} + +static boolean isTimerActive(timer16_Sequence_t timer) +{ + // returns true if any servo is active on this timer + for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { + if(SERVO(timer,channel).Pin.isActive == true) + return true; + } + return false; +} + + +/****************** end of static functions ******************************/ + +Servo::Servo() +{ + if( ServoCount < MAX_SERVOS) { + this->servoIndex = ServoCount++; // assign a servo index to this instance + servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009 + } + else + this->servoIndex = INVALID_SERVO ; // too many servos +} + +uint8_t Servo::attach(int pin) +{ + return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); +} + +uint8_t Servo::attach(int pin, int min, int max) +{ + if(this->servoIndex < MAX_SERVOS ) { + pinMode( pin, OUTPUT) ; // set servo pin to output + servos[this->servoIndex].Pin.nbr = pin; + // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 + this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS + this->max = (MAX_PULSE_WIDTH - max)/4; + // initialize the timer if it has not already been initialized + timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); + if(isTimerActive(timer) == false) + initISR(timer); + servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive + } + return this->servoIndex ; +} + +void Servo::detach() +{ + servos[this->servoIndex].Pin.isActive = false; + timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); + if(isTimerActive(timer) == false) { + finISR(timer); + } +} + +void Servo::write(int value) +{ + if(value < MIN_PULSE_WIDTH) + { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) + if(value < 0) value = 0; + if(value > 180) value = 180; + value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); + } + this->writeMicroseconds(value); +} + +void Servo::writeMicroseconds(int value) +{ + // calculate and store the values for the given channel + byte channel = this->servoIndex; + if( (channel < MAX_SERVOS) ) // ensure channel is valid + { + if( value < SERVO_MIN() ) // ensure pulse width is valid + value = SERVO_MIN(); + else if( value > SERVO_MAX() ) + value = SERVO_MAX(); + + value = value - TRIM_DURATION; + value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009 + + uint8_t oldSREG = SREG; + cli(); + servos[channel].ticks = value; + SREG = oldSREG; + } +} + +int Servo::read() // return the value as degrees +{ + return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); +} + +int Servo::readMicroseconds() +{ + unsigned int pulsewidth; + if( this->servoIndex != INVALID_SERVO ) + pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ; // 12 aug 2009 + else + pulsewidth = 0; + + return pulsewidth; +} + +bool Servo::attached() +{ + return servos[this->servoIndex].Pin.isActive ; +} + +#endif // ARDUINO_ARCH_AVR + diff --git a/arduino/ruka_lafvin/Library/Servo/src/avr/ServoTimers.h b/arduino/ruka_lafvin/Library/Servo/src/avr/ServoTimers.h new file mode 100644 index 0000000..29c1ae2 --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/src/avr/ServoTimers.h @@ -0,0 +1,59 @@ +/* + Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + Copyright (c) 2009 Michael Margolis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* + * Defines for 16 bit timers used with Servo library + * + * If _useTimerX is defined then TimerX is a 16 bit timer on the current board + * timer16_Sequence_t enumerates the sequence that the timers should be allocated + * _Nbr_16timers indicates how many 16 bit timers are available. + */ + +/** + * AVR Only definitions + * -------------------- + */ + +// Say which 16 bit timers can be used and in what order +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define _useTimer5 +#define _useTimer1 +#define _useTimer3 +#define _useTimer4 +typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t; + +#elif defined(__AVR_ATmega32U4__) +#define _useTimer1 +typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t; + +#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) +#define _useTimer3 +#define _useTimer1 +typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t; + +#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) +#define _useTimer3 +#define _useTimer1 +typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t; + +#else // everything else +#define _useTimer1 +typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t; +#endif + diff --git a/arduino/ruka_lafvin/Library/Servo/src/sam/Servo.cpp b/arduino/ruka_lafvin/Library/Servo/src/sam/Servo.cpp new file mode 100644 index 0000000..21f901f --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/src/sam/Servo.cpp @@ -0,0 +1,283 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#if defined(ARDUINO_ARCH_SAM) + +#include +#include + +#define usToTicks(_us) (( clockCyclesPerMicrosecond() * _us) / 32) // converts microseconds to tick +#define ticksToUs(_ticks) (( (unsigned)_ticks * 32)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds + +#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays + +static servo_t servos[MAX_SERVOS]; // static array of servo structures + +uint8_t ServoCount = 0; // the total number of attached servos + +static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) + +// convenience macros +#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo +#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer +#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel +#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel + +#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo +#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo + +/************ static functions common to all instances ***********************/ + +//------------------------------------------------------------------------------ +/// Interrupt handler for the TC0 channel 1. +//------------------------------------------------------------------------------ +void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel); +#if defined (_useTimer1) +void HANDLER_FOR_TIMER1(void) { + Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); +} +#endif +#if defined (_useTimer2) +void HANDLER_FOR_TIMER2(void) { + Servo_Handler(_timer2, TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); +} +#endif +#if defined (_useTimer3) +void HANDLER_FOR_TIMER3(void) { + Servo_Handler(_timer3, TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); +} +#endif +#if defined (_useTimer4) +void HANDLER_FOR_TIMER4(void) { + Servo_Handler(_timer4, TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); +} +#endif +#if defined (_useTimer5) +void HANDLER_FOR_TIMER5(void) { + Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); +} +#endif + +void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) +{ + // clear interrupt + tc->TC_CHANNEL[channel].TC_SR; + if (Channel[timer] < 0) { + tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer + } else { + if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true) { + digitalWrite(SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated + } + } + + Channel[timer]++; // increment to the next channel + if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { + tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks; + if(SERVO(timer,Channel[timer]).Pin.isActive == true) { // check if activated + digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high + } + } + else { + // finished all channels so wait for the refresh period to expire before starting over + if( (tc->TC_CHANNEL[channel].TC_CV) + 4 < usToTicks(REFRESH_INTERVAL) ) { // allow a few ticks to ensure the next OCR1A not missed + tc->TC_CHANNEL[channel].TC_RA = (unsigned int)usToTicks(REFRESH_INTERVAL); + } + else { + tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + 4; // at least REFRESH_INTERVAL has elapsed + } + Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel + } +} + +static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) +{ + pmc_enable_periph_clk(id); + TC_Configure(tc, channel, + TC_CMR_TCCLKS_TIMER_CLOCK3 | // MCK/32 + TC_CMR_WAVE | // Waveform mode + TC_CMR_WAVSEL_UP_RC ); // Counter running up and reset when equals to RC + + /* 84MHz, MCK/32, for 1.5ms: 3937 */ + TC_SetRA(tc, channel, 2625); // 1ms + + /* Configure and enable interrupt */ + NVIC_EnableIRQ(irqn); + // TC_IER_CPAS: RA Compare + tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS; + + // Enables the timer clock and performs a software reset to start the counting + TC_Start(tc, channel); +} + +static void initISR(timer16_Sequence_t timer) +{ +#if defined (_useTimer1) + if (timer == _timer1) + _initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1); +#endif +#if defined (_useTimer2) + if (timer == _timer2) + _initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2); +#endif +#if defined (_useTimer3) + if (timer == _timer3) + _initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3); +#endif +#if defined (_useTimer4) + if (timer == _timer4) + _initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4); +#endif +#if defined (_useTimer5) + if (timer == _timer5) + _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5); +#endif +} + +static void finISR(timer16_Sequence_t timer) +{ +#if defined (_useTimer1) + TC_Stop(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); +#endif +#if defined (_useTimer2) + TC_Stop(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); +#endif +#if defined (_useTimer3) + TC_Stop(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); +#endif +#if defined (_useTimer4) + TC_Stop(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); +#endif +#if defined (_useTimer5) + TC_Stop(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); +#endif +} + + +static boolean isTimerActive(timer16_Sequence_t timer) +{ + // returns true if any servo is active on this timer + for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { + if(SERVO(timer,channel).Pin.isActive == true) + return true; + } + return false; +} + +/****************** end of static functions ******************************/ + +Servo::Servo() +{ + if (ServoCount < MAX_SERVOS) { + this->servoIndex = ServoCount++; // assign a servo index to this instance + servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values + } else { + this->servoIndex = INVALID_SERVO; // too many servos + } +} + +uint8_t Servo::attach(int pin) +{ + return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); +} + +uint8_t Servo::attach(int pin, int min, int max) +{ + timer16_Sequence_t timer; + + if (this->servoIndex < MAX_SERVOS) { + pinMode(pin, OUTPUT); // set servo pin to output + servos[this->servoIndex].Pin.nbr = pin; + // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 + this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS + this->max = (MAX_PULSE_WIDTH - max)/4; + // initialize the timer if it has not already been initialized + timer = SERVO_INDEX_TO_TIMER(servoIndex); + if (isTimerActive(timer) == false) { + initISR(timer); + } + servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive + } + return this->servoIndex; +} + +void Servo::detach() +{ + timer16_Sequence_t timer; + + servos[this->servoIndex].Pin.isActive = false; + timer = SERVO_INDEX_TO_TIMER(servoIndex); + if(isTimerActive(timer) == false) { + finISR(timer); + } +} + +void Servo::write(int value) +{ + // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) + if (value < MIN_PULSE_WIDTH) + { + if (value < 0) + value = 0; + else if (value > 180) + value = 180; + + value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); + } + writeMicroseconds(value); +} + +void Servo::writeMicroseconds(int value) +{ + // calculate and store the values for the given channel + byte channel = this->servoIndex; + if( (channel < MAX_SERVOS) ) // ensure channel is valid + { + if (value < SERVO_MIN()) // ensure pulse width is valid + value = SERVO_MIN(); + else if (value > SERVO_MAX()) + value = SERVO_MAX(); + + value = value - TRIM_DURATION; + value = usToTicks(value); // convert to ticks after compensating for interrupt overhead + servos[channel].ticks = value; + } +} + +int Servo::read() // return the value as degrees +{ + return map(readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); +} + +int Servo::readMicroseconds() +{ + unsigned int pulsewidth; + if (this->servoIndex != INVALID_SERVO) + pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION; + else + pulsewidth = 0; + + return pulsewidth; +} + +bool Servo::attached() +{ + return servos[this->servoIndex].Pin.isActive; +} + +#endif // ARDUINO_ARCH_SAM + diff --git a/arduino/ruka_lafvin/Library/Servo/src/sam/ServoTimers.h b/arduino/ruka_lafvin/Library/Servo/src/sam/ServoTimers.h new file mode 100644 index 0000000..13f736a --- /dev/null +++ b/arduino/ruka_lafvin/Library/Servo/src/sam/ServoTimers.h @@ -0,0 +1,88 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* + * Defines for 16 bit timers used with Servo library + * + * If _useTimerX is defined then TimerX is a 16 bit timer on the current board + * timer16_Sequence_t enumerates the sequence that the timers should be allocated + * _Nbr_16timers indicates how many 16 bit timers are available. + */ + +/** + * SAM Only definitions + * -------------------- + */ + +// For SAM3X: +#define _useTimer1 +#define _useTimer2 +#define _useTimer3 +#define _useTimer4 +#define _useTimer5 + +/* + TC0, chan 0 => TC0_Handler + TC0, chan 1 => TC1_Handler + TC0, chan 2 => TC2_Handler + TC1, chan 0 => TC3_Handler + TC1, chan 1 => TC4_Handler + TC1, chan 2 => TC5_Handler + TC2, chan 0 => TC6_Handler + TC2, chan 1 => TC7_Handler + TC2, chan 2 => TC8_Handler + */ + +#if defined (_useTimer1) +#define TC_FOR_TIMER1 TC1 +#define CHANNEL_FOR_TIMER1 0 +#define ID_TC_FOR_TIMER1 ID_TC3 +#define IRQn_FOR_TIMER1 TC3_IRQn +#define HANDLER_FOR_TIMER1 TC3_Handler +#endif +#if defined (_useTimer2) +#define TC_FOR_TIMER2 TC1 +#define CHANNEL_FOR_TIMER2 1 +#define ID_TC_FOR_TIMER2 ID_TC4 +#define IRQn_FOR_TIMER2 TC4_IRQn +#define HANDLER_FOR_TIMER2 TC4_Handler +#endif +#if defined (_useTimer3) +#define TC_FOR_TIMER3 TC1 +#define CHANNEL_FOR_TIMER3 2 +#define ID_TC_FOR_TIMER3 ID_TC5 +#define IRQn_FOR_TIMER3 TC5_IRQn +#define HANDLER_FOR_TIMER3 TC5_Handler +#endif +#if defined (_useTimer4) +#define TC_FOR_TIMER4 TC0 +#define CHANNEL_FOR_TIMER4 2 +#define ID_TC_FOR_TIMER4 ID_TC2 +#define IRQn_FOR_TIMER4 TC2_IRQn +#define HANDLER_FOR_TIMER4 TC2_Handler +#endif +#if defined (_useTimer5) +#define TC_FOR_TIMER5 TC0 +#define CHANNEL_FOR_TIMER5 0 +#define ID_TC_FOR_TIMER5 ID_TC0 +#define IRQn_FOR_TIMER5 TC0_IRQn +#define HANDLER_FOR_TIMER5 TC0_Handler +#endif + +typedef enum { _timer1, _timer2, _timer3, _timer4, _timer5, _Nbr_16timers } timer16_Sequence_t ; + diff --git a/arduino/ruka_lafvin/Smart Robot Arm Kit.pdf b/arduino/ruka_lafvin/Smart Robot Arm Kit.pdf new file mode 100644 index 0000000..0d2a92c Binary files /dev/null and b/arduino/ruka_lafvin/Smart Robot Arm Kit.pdf differ diff --git a/karel/.htaccess b/karel/.htaccess new file mode 100644 index 0000000..1d3b11f --- /dev/null +++ b/karel/.htaccess @@ -0,0 +1,4 @@ +SetHandler None +AddDefaultCharset utf-8 +AddCharset utf-8 .js +AddCharset utf-8 .css diff --git a/karel/AUTHORS b/karel/AUTHORS new file mode 100644 index 0000000..3e312f6 --- /dev/null +++ b/karel/AUTHORS @@ -0,0 +1 @@ +Oldřich Jedlička diff --git a/karel/COPYING b/karel/COPYING new file mode 100644 index 0000000..088b500 --- /dev/null +++ b/karel/COPYING @@ -0,0 +1,25 @@ +Copyright (c) 2006-2013, Oldrich Jedlicka +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the original author nor the names of the contributors + (see AUTHORS) may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/karel/ChangeLog b/karel/ChangeLog new file mode 100644 index 0000000..73e777b --- /dev/null +++ b/karel/ChangeLog @@ -0,0 +1,1762 @@ +2013-01-10 Oldřich Jedlička + + * src/scripts/nacitaci-ukladaci-funkce.js: + + Upraveny počty viditelných řádek při ukládání. + + * COPYING, KOPIROVANI, src/index.html.in, src/napoveda.html.in, + src/priklady.html.in: + + Doplněný Copyright. + + * NOVINKY: + + Doplněny novinky. + + * configure.ac: + + Příprava na novou verzi. + + * src/scripts/okno-ulozeni-a-exportu.js: + + Kvůli iPadu změněna '); +document.write(''); +document.write(''); + +document.write(''); + +// =========================================================================== +// =~ Základní nastavení editoru ~============================================ + +editor.prikaz_novy(true); + +// Kvůli Konqueroru, který obnovuje obsahy textových polí po svém... +po_spusteni( function() { editor.prikaz_novy(true); } ); diff --git a/karel/scripts/prikazy-tvar-slovnik.js b/karel/scripts/prikazy-tvar-slovnik.js new file mode 100644 index 0000000..b728889 --- /dev/null +++ b/karel/scripts/prikazy-tvar-slovnik.js @@ -0,0 +1,48 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +// JavaScript - základní tvar slovníku + +// =========================================================================== +// =~ Vygenerování slovníku ~================================================= + +document.write('
'); + +document.write('
Slovník (Karel verze ' + + verze_karla + ')
'); +document.write('
' + + '
'); + +document.write('
'); +for ( var i = 0; i < prikazy.nastroje.length; i++ ) { + var nastroj = prikazy.nastroje[i]; + if ( nastroj != null ) { + tvoric.zapis_tlacitko(false, prikazy.nastroje.id_prefix+nastroj[0], + prikazy.nastroje.mys, '\''+nastroj[0]+'\'', + '{ikona:\''+nastroj[1]+'\',nadpis:\''+nastroj[2]+'\',popis:\''+nastroj[3]+'\'}'); + } else { + tvoric.zapis_tlacitko(true); + } +} +document.write('
'); +document.write('Vybraný příkaz:'); +document.write(''+prikazy.zadny_prikaz+''); + +document.write('
'); + +// =========================================================================== +// =~ Základní nastavení slovníku ~=========================================== + +for ( var i = 0; i < prikazy.seznam.length; i++ ) { + var prikaz = prikazy.seznam[i]; + if ( prikaz.zobrazit ) { + prikazy.pridej( prikaz ); + } +} diff --git a/karel/scripts/slovnik.js b/karel/scripts/slovnik.js new file mode 100644 index 0000000..18e498c --- /dev/null +++ b/karel/scripts/slovnik.js @@ -0,0 +1,246 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +// JavaScript - slovník + +// =========================================================================== +// =~ Globální proměnné ~===================================================== + +// Příkazy +// +// Každý příkaz má následující vlastnosti: +// +// jmeno jméno příkazu +// systemovy true, pokud se jedná o systémový příkaz +// zobrazit true, pokud má být příkaz zobrazen +// ignoruj true, pokud příkaz neprovádí žádnou činnost +// hlavicka true, pokud se příkaz může vyskytovat v hlavičce (před +// názvem příkazu) +// telo pole jednotlivých řádek. Jedna řádka příkazu je pole dvou +// hodnot - příkazu a parametrů +// syntaxe true, pokud příkaz vyžaduje kontrolu syntaxe (všechny +// příkazy, které neprovádí žádnou činnost) +// tooltip text nápovědy (není povinné) +// spust vykonání příkazu, provádí i kontrolu syntaxe (když je +// atribut syntaxe nastaven na true) +// formatovac formátování příkazu. Pokud chybí, použije se obecný +// formátovač +// rozpoznavac rozpoznání příkazu. Pokud chybí, použije se obecný +// rozpoznávač +// ukladac ukládání příkazu. Pokud chybí, použije se obecní funkce +// ukládání +// kompatibilita verze, které příkaz znají +// verze_ulozeni verze, ve kterých se příkaz ukládá. Pokud se v dané verzi +// neukládá, je zobrazeno varování. Pokud se má uložit, ale +// příkaz není s verzí kompatibilní, je zobrazena chyba. Pokud +// se má uložit a je s verzí kompatibilní, pak se ukládá +// prikaz true, pokud se jedná o příkaz. Pouze pro systémové příkazy +// a to jen pro zobrazení v chybové hlášce +// +// Navíc existuje pro každý příkaz prikazy.prikaz["PŘÍKAZ"] +// +prikazy.seznam = new Array( + { jmeno: "prázdná řádka", systemovy: true, zobrazit: false, ignoruj: true, + hlavicka: true, + rozpoznavac: prikazy.rozpoznavac.prazdna_radka, + formatovac: prikazy.formatovac.prazdna_radka, + kompatibilita: prikazy.min_VERZE_20, + verze_ulozeni: prikazy.min_VERZE_20 + }, + { jmeno: "komentář", systemovy: true, zobrazit: false, ignoruj: true, + hlavicka: true, + rozpoznavac: prikazy.rozpoznavac.komentar, + formatovac: prikazy.formatovac.komentar, + ukladac: data.ukladani.uloz_komentar, + nacitac: data.nacitani.nacti_komentar, + kompatibilita: prikazy.min_VERZE_20, + verze_ulozeni: prikazy.min_VERZE_20 + }, + { jmeno: "název příkazu", systemovy: true, zobrazit: false, ignoruj: true, + hlavicka: true, + rozpoznavac: prikazy.rozpoznavac.nazev, + formatovac: prikazy.formatovac.nazev, + ukladac: data.ukladani.uloz_nazev, + nacitac: data.nacitani.nacti_nazev, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_20 + }, + { jmeno: "prázdná řádka", systemovy: true, zobrazit: false, ignoruj: true, + rozpoznavac: prikazy.rozpoznavac.prazdna_radka, + formatovac: prikazy.formatovac.prazdna_radka, + kompatibilita: prikazy.min_VERZE_20, + verze_ulozeni: prikazy.min_VERZE_20 + }, + { jmeno: "komentář", systemovy: true, zobrazit: false, ignoruj: true, + rozpoznavac: prikazy.rozpoznavac.komentar, + formatovac: prikazy.formatovac.komentar, + ukladac: data.ukladani.uloz_komentar, + nacitac: data.nacitani.nacti_komentar, + kompatibilita: prikazy.min_VERZE_20, + verze_ulozeni: prikazy.min_VERZE_20 + }, + { jmeno: "KONEC, JINAK", systemovy: true, zobrazit: false, + spust: prikazy.jadro.KONEC_JINAK, + syntaxe: true, + formatovac: prikazy.formatovac.konec, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "KONEC", systemovy: true, zobrazit: false, + spust: prikazy.jadro.KONEC, + syntaxe: true, + formatovac: prikazy.formatovac.konec, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "KDYŽ", systemovy: true, zobrazit: false, + spust: prikazy.jadro.KDYZ, + syntaxe: true, + rozpoznavac: prikazy.rozpoznavac.podminka, + formatovac: prikazy.formatovac.podminka, + nacitac: data.nacitani.nacti_podminku, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "DOKUD", systemovy: true, zobrazit: false, + spust: prikazy.jadro.DOKUD, + syntaxe: true, + rozpoznavac: prikazy.rozpoznavac.podminka, + formatovac: prikazy.formatovac.podminka, + nacitac: data.nacitani.nacti_podminku, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "OPAKUJ", systemovy: true, zobrazit: false, + spust: prikazy.jadro.OPAKUJ, + syntaxe: true, + rozpoznavac: prikazy.rozpoznavac.cyklus, + formatovac: prikazy.formatovac.cyklus, + ukladac: data.ukladani.uloz_OPAKUJ, + nacitac: data.nacitani.nacti_OPAKUJ, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "AŽ", systemovy: true, zobrazit: false, + spust: prikazy.jadro.AZ, + syntaxe: true, + rozpoznavac: prikazy.rozpoznavac.podminka, + formatovac: prikazy.formatovac.podminka, + nacitac: data.nacitani.nacti_podminku, + kompatibilita: prikazy.min_VERZE_11, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "RYCHLE", systemovy: true, zobrazit: false, + spust: prikazy.jadro.RYCHLE, + syntaxe: true, + formatovac: prikazy.formatovac.odsazeni, + kompatibilita: prikazy.min_VERZE_12, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "POMALU", systemovy: true, zobrazit: false, + spust: prikazy.jadro.POMALU, + syntaxe: true, + formatovac: prikazy.formatovac.predsazeni, + kompatibilita: prikazy.min_VERZE_12, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "STOP", systemovy: true, zobrazit: false, + spust: prikazy.jadro.STOP, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true + }, + { jmeno: "KROK", systemovy: true, zobrazit: true, + spust: prikazy.jadro.KROK, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true, + tooltip: "Posune Karla o jedno políčko dopředu" + }, + { jmeno: "VLEVO-VBOK", systemovy: true, zobrazit: true, + spust: prikazy.jadro.VLEVO_VBOK, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true, + tooltip: "Otočí Karla jednou vlevo" + }, + { jmeno: "POLOŽ", systemovy: true, zobrazit: true, + spust: prikazy.jadro.POLOZ, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true, + tooltip: "Karel položí jednu značku, pokud je na políčku místo" + }, + { jmeno: "ZVEDNI", systemovy: true, zobrazit: true, + spust: prikazy.jadro.ZVEDNI, + kompatibilita: prikazy.min_VERZE_10, + verze_ulozeni: prikazy.min_VERZE_10, + prikaz: true, + tooltip: "Karel zvedne jednu značku, pokud na políčku nějaká je" + } +); + +// Příkazy přístupné podle jména +prikazy.prikaz = new Object(); + +// Textové řetězce spojené s příkazy +prikazy.JE = "JE"; +prikazy.NENI = "NENÍ"; +prikazy.KRAT = "KRÁT"; +prikazy.KRAT_text = escape(prikazy.KRAT); +prikazy._KRAT = "-" + prikazy.KRAT; +prikazy.podminky = [ + { jmeno: "ZEĎ", test: mesto.JE_ZED }, + { jmeno: "ZNAČKA", test: mesto.JE_ZNACKA }, + { jmeno: "DOMOV", test: mesto.JE_DOMOV }, + { jmeno: "VÝCHOD", test: mesto.JE_VYCHOD }, + { jmeno: "SEVER", test: mesto.JE_SEVER }, + { jmeno: "ZÁPAD", test: mesto.JE_ZAPAD }, + { jmeno: "JIH", test: mesto.JE_JIH } +]; + + +// =========================================================================== +// =~ Základní nastavení ~==================================================== + +for ( var i = 0; i < prikazy.seznam.length; i++ ) { + var prikaz = prikazy.seznam[i]; + if (! (prikaz.jmeno in prikazy.prikaz)) { + prikazy.prikaz[prikaz.jmeno] = prikaz; + } +} + +// =========================================================================== +// =~ Příkazové konstanty ~=================================================== + +prikazy.HLAVICKA_KOMENTAR = prikazy.prikaz["komentář"]; +prikazy.HLAVICKA_PRAZDNA_RADKA = prikazy.prikaz["prázdná řádka"]; +prikazy.NAZEV = prikazy.prikaz["název příkazu"]; +prikazy.KONEC_JINAK = prikazy.prikaz["KONEC, JINAK"]; +prikazy.KONEC = prikazy.prikaz["KONEC"]; +prikazy.KDYZ = prikazy.prikaz["KDYŽ"]; +prikazy.DOKUD = prikazy.prikaz["DOKUD"]; +prikazy.OPAKUJ = prikazy.prikaz["OPAKUJ"]; +prikazy.AZ = prikazy.prikaz["AŽ"]; +prikazy.RYCHLE = prikazy.prikaz["RYCHLE"]; +prikazy.POMALU = prikazy.prikaz["POMALU"]; +prikazy.STOP = prikazy.prikaz["STOP"]; +prikazy.KROK = prikazy.prikaz["KROK"]; +prikazy.VLEVO_VBOK = prikazy.prikaz["VLEVO_VBOK"]; +prikazy.POLOZ = prikazy.prikaz["POLOŽ"]; +prikazy.ZVEDNI = prikazy.prikaz["ZVEDNI"]; diff --git a/karel/scripts/styly-funkce.js b/karel/scripts/styly-funkce.js new file mode 100644 index 0000000..7840a1a --- /dev/null +++ b/karel/scripts/styly-funkce.js @@ -0,0 +1,404 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +// JavaScript - funkce pro práci se styly + +// =========================================================================== +// =~ Tovární nastavení ~===================================================== + +// Styl nastavený uživatelem +nastaveni.styl = hodnota_cookie("styl"); + +// =========================================================================== +// =~ Globální proměnné ~===================================================== + +// Názvy alternativních stylů +styly = new Array(); + +// Všechny pojmenované styly +styly.pojmenovane_styly = new Array(); + +// Všechny obrázky ve všech stylech +styly.obrazky = new Array(); +styly.posledni_obrazek = undefined; +styly.pridane_obrazky = " "; + +// Stav nahrávání +styly.NAHRANO = 0; +styly.CHYBA = 1; +styly.ZRUSENO = 2; + +// Všechny soubory se styly, pokud se nepodařilo zjistit obrázky +styly.soubory = new Array(); +styly.posledni_soubor = undefined; +styly.pridane_soubory = " "; + +// =========================================================================== +// =~ Základní nastavení ~==================================================== + +// Zjisti všechny styly v dokumentu +var linky = document.getElementsByTagName("link"); +var link_styly = new Array(); +var nacteno = " "; +for ( var i = 0; i < linky.length; i++ ) { + if ( linky[i].getAttribute("rel").indexOf("stylesheet") != -1 ) { + link_styly.push( linky[i] ); + var jmeno; + if ( (jmeno=linky[i].getAttribute("title")) ) { + styly.pojmenovane_styly.push( linky[i] ); + var jmeno_esc = escape(jmeno); + if ( nacteno.indexOf(" "+jmeno_esc+" ") == -1 ) { + var id=linky[i].getAttribute("id"); + if ( nastaveni.styl == null ) { + nastaveni.styl = jmeno; + } + styly.push( {jmeno:jmeno, trida:id} ); + nacteno += jmeno_esc+" "; + } + } + } +} + +// =========================================================================== +// =~ Načti všechny obrázky ~================================================= + +// Přidá obrázek do fronty, pokud ještě nebyl přidán +styly.pridej_obrazek = function (obrazek) +{ + var escape_url = escape(obrazek.url); + if ( styly.pridane_obrazky.indexOf(" "+escape_url+" ") == -1 ) { + styly.obrazky.push(obrazek); + styly.pridane_obrazky += escape_url + " "; + return true; + } else { + return false; + } +} + +// Připraví obrázek na automatické stažení na pozadí +styly.priprav_obrazek = function (url) +{ + var obrazek = new Image(); + obrazek.onload = function () { + window.setTimeout(function () { styly.dalsi_obrazek(styly.NAHRANO); }, 0); + } + obrazek.onerror = function () { + window.setTimeout(function () { styly.dalsi_obrazek(styly.CHYBA); }, 0); + } + obrazek.onabort = function () { + window.setTimeout(function () { styly.dalsi_obrazek(styly.ZRUSENO); }, 0); + } + return { url: url, obrazek: obrazek }; +} + +// Spouští stahování obrázku (dalšího) na pozadí +styly.dalsi_obrazek = function (posledni_stav) +{ + if ( this.posledni_obrazek == undefined ) { + if ( !this.obrazky.length ) { + return; + } + this.posledni_obrazek = 0; + } else { + if ( posledni_stav == styly.NAHRANO ) { + ladici_vypis(DETAIL, "styly.dalsi_obrazek", + this.obrazky[this.posledni_obrazek].url, "nahráno"); + this.posledni_obrazek++; + } else { + if ( posledni_stav == styly.CHYBA ) { + ladici_vypis(CHYBA, "styly.dalsi_obrazek", + this.obrazky[this.posledni_obrazek].url, + "nepodařilo se nahrát obrázek"); + } else { + ladici_vypis(CHYBA, "styly.dalsi_obrazek", + this.obrazky[this.posledni_obrazek].url, "zrušeno"); + } + return; + } + } + if ( this.posledni_obrazek >= this.obrazky.length ) { + if ( this.obrazky.length ) { + ladici_vypis(INFORMACE, "styly.dalsi_obrazek", "nahráno " + + this.obrazky.length + " obrázků do vyrovnávací paměti"); + } + return; + } + var obrazek = this.obrazky[this.posledni_obrazek]; + if ( ! obrazek ) return; + obrazek.obrazek.src = obrazek.url; +} + +styly.notifikace_nahravace = function () +{ + if ( styly.posledni_soubor >= styly.soubory.length ) return; + + var soubor = styly.soubory[styly.posledni_soubor]; + if ( soubor.notifikovano ) return; + + var nahravac = styly.soubory[styly.posledni_soubor].nahravac; + if ( nahravac.readyState == 4 ) { + soubor.notifikovano = true; + if ( nahravac.status == 200 || nahravac.status == 304 + || ( nahravac.status == 0 && nahravac.responseText ) ) { + setTimeout( function() { styly.dalsi_soubor(styly.NAHRANO); }, 0 ); + } else { + setTimeout( function() { styly.dalsi_soubor(styly.CHYBA); }, 0 ); + } + } +} + +// =========================================================================== +// =~ Vlastní zpracování CSS ~================================================ + +// Přidá soubor do fronty, pokud ještě nebyl přidán +styly.pridej_soubor = function (url) +{ + var escape_url = escape(url); + if ( styly.pridane_soubory.indexOf(" "+escape_url+" ") == -1 ) { + styly.soubory.push( { url: url } ); + styly.pridane_soubory += escape_url + " "; + return true; + } else { + return false; + } +} + +// Započítej soubor do souborů ve frontě +styly.zapocitej_soubor = function (url) +{ + var escape_url = escape(url); + if ( styly.pridane_soubory.indexOf(" "+escape_url+" ") == -1 ) { + styly.pridane_soubory += escape_url + " "; + return true; + } else { + return false; + } +} + +// Spouští stahování obrázku (dalšího) na pozadí +styly.dalsi_soubor = function (posledni_stav) +{ + if ( this.posledni_soubor == undefined ) { + this.posledni_soubor = 0; + } else { + var soubor = this.soubory[this.posledni_soubor]; + var url = soubor.url.slice(soubor.url.indexOf("style/")); + var nahravac = soubor.nahravac; + if ( posledni_stav == styly.NAHRANO ) { + ladici_vypis(DETAIL, "styly.dalsi_soubor", url, "nahráno"); + this.zpracuj_soubor( url, nahravac.responseText ); + this.posledni_soubor++; + delete soubor.nahravac; + } else { + ladici_vypis(CHYBA, "styly.dalsi_soubor", + soubor.url, "nepodařilo se nahrát"); + return; + } + } + if ( this.posledni_soubor >= this.soubory.length ) { + if ( this.obrazky.length == 0 ) { + ladici_vypis(CHYBA, "styly-funkce", + "vyrovnávací paměť obrázků je prázdná, očekávejte různá zpoždění"); + if ( /^https?:[\/][\/]/.exec(document.URL) ) { + alert( + "Nelze dopředu načíst všechny obrázky, " + + "nenalezena vhodná metoda.\n\nOčekávejte různá zpoždění." ); + } + } else { + this.dalsi_obrazek(); + } + return; + } + var soubor = this.soubory[this.posledni_soubor]; + if ( soubor && soubor.url ) { + soubor.nahravac = ajax.vrat_nahravac(); + ajax.nahraj_soubor_pozdeji(soubor.nahravac, soubor.url, + styly.notifikace_nahravace); + } +} + +// Zpracování obsahu souboru se styly +styly.zpracuj_soubor = function (soubor, obsah) +{ + var pridano = 0; + var url_obrazku; + var regex = /(-image|filter:progid):[^"']*['"]\.\.\/([^'"]+)['"]/g; // " + while ( url_obrazku = regex.exec(obsah) ) { + var obrazek = styly.priprav_obrazek( url_obrazku[2] ); + if ( styly.pridej_obrazek(obrazek) ) { + pridano++; + } + } + ladici_vypis(LADENI, "styly.zpracuj_soubor", soubor, "přidáno " + pridano + " obrázků"); +} + +// =========================================================================== +// =~ Zjisti všechny obrázky ~================================================ + +styly.nahraj_obrazky = function () +{ + // Které linky byly analyzovány + var pocet_analyzovano = 0; + + // Projdi všechny styly a najdi background-image + if ( document.styleSheets ) { + ladici_vypis(LADENI, "styly.nahraj_obrazky", "zkouším metodu document.styleSheets"); + for ( var i = 0; i < document.styleSheets.length; i++ ) { + var styleSheet = document.styleSheets[i]; + var rules = new Array(); + if ( styleSheet.rules ) rules = styleSheet.rules; + if ( !rules && styleSheet.cssRules ) rules = styleSheet.cssRules; + if ( !rules ) continue; + var nacteno = 0; + for ( var j = 0; j < rules.length; j++ ) { + var cssRule = rules[j]; + var style = cssRule.style; + if ( typeof(style) != "object" ) continue; + + var url = undefined; + if ( style.backgroundImage && style.backgroundImage != "none" ) { + url = style.backgroundImage; + } else if ( style.filter ) { + url = style.filter; + } + + if ( url && url.length > 4 ) { + url = url.slice(url.indexOf('images/')); + url = url.slice(0, url.indexOf('"')); + var obrazek = styly.priprav_obrazek( url ); + if ( styly.pridej_obrazek(obrazek) ) { + nacteno++; + } + } + } + var styl = styleSheet.href.slice(styleSheet.href.indexOf('style/')); + ladici_vypis(LADENI, "styly.nahraj_obrazky", styl, "nalezeno " + nacteno + " obrázků"); + + if ( nacteno && styly.zapocitej_soubor(styleSheet.href) ) { + pocet_analyzovano++; + } + } + ladici_vypis(LADENI, "styly.nahraj_obrazky", + "nalezeno " + pocet_analyzovano + " stylových souborů prohlížeče"); + } else { + ladici_vypis(LADENI, "styly.nahraj_obrazky", "metoda document.styleSheets není dostupná"); + } + + // Alternativní metoda - XMLHttpRequest + if ( styly.obrazky.length == 0 || pocet_analyzovano < link_styly.length ) { + // Načti všechny styly ručně a najdi v nich background-image + if ( ajax.je_funkcni() ) { + if ( styly.obrazky.length > 0 ) { + ladici_vypis(LADENI, "styly.nahraj_obrazky", "zkouším dočíst styly metodou XMLHttpRequest"); + } else { + ladici_vypis(LADENI, "styly.nahraj_obrazky", "zkouším metodu XMLHttpRequest"); + } + for ( var i = 0; i < link_styly.length; i++ ) { + var url = link_styly[i].href; + if ( styly.pridej_soubor(url) ) { + var styl = url.slice(url.indexOf('style/')); + ladici_vypis(LADENI, "styly.nahraj_obrazky", styl, "bude načten"); + pocet_analyzovano++; + } + } + ladici_vypis(INFORMACE, "styly.nahraj_obrazky", + "nalezeno celkem " + pocet_analyzovano + " stylových souborů"); + } else { + if ( pocet_analyzovano == 0 ) { + ladici_vypis(CHYBA, "styly.nahraj_obrazky", + "nenalezena metoda pro načtení všech obrázků"); + } else { + ladici_vypis(CHYBA, "styly.nahraj_obrazky", + "nenalezena metoda pro dočtení zbylých stylových souborů"); + } + } + } else { + ladici_vypis(INFORMACE, "styly.nahraj_obrazky", + "nalezeno celkem " + pocet_analyzovano + " stylových souborů"); + } + + setTimeout( function() { styly.dalsi_soubor(); }, 0 ); +} + +po_spusteni( function() { styly.nahraj_obrazky(); } ); + +// =========================================================================== +// =~ Aktivuj správný styl ~================================================== + +for ( var i = 0; i < styly.pojmenovane_styly.length; i++ ) { + var link = styly.pojmenovane_styly[i]; + var jmeno = link.getAttribute("title"); + if ( jmeno != nastaveni.styl ) { + link.disabled = true; + } else { + link.disabled = false; + } +} + +// =========================================================================== +// =~ Základní funkce pro práci se styly ~==================================== + +styly.zmen_styl = function(styl, povolit) +{ + for ( var i = 0; i < styly.pojmenovane_styly.length; i++ ) { + var link = styly.pojmenovane_styly[i]; + if ( (povolit && link.title == styl) || + (!povolit && link.title != styl) ) { + link.disabled = !povolit; + ladici_vypis(LADENI, "styly.zmen_styl", link.href.match(/style.*/)[0], + "vybraný:"+formatuj_text(!link.disabled)); + } + } +} + +// Vyber styl po puštění klávesy +styly.vyber_klavesou = function() +{ + var styl; + ladici_vypis(LADENI, "styly.vyber_klavesou", "hledám vybraný styl"); + for ( var i = 0; i < styly.length; i++ ) { + var element = document.getElementById('styl-'+i); + if ( element && element.checked ) { + styl = styly[i].jmeno; + ladici_vypis(LADENI, "styly.vyber_klavesou", "nalezen styl "+styl); + } + } + + if ( !styl ) { + ladici_vypis(CHYBA, "styly.vyber_klavesou", "nenalezen vybraný styl"); + return false; + } else { + this.vyber(styl); + } +} + +// Vyber styl +styly.vyber = function(styl) +{ + if ( styl == nastaveni.styl ) { + ladici_vypis(LADENI, "styly.vyber", "žádná změna stylu, zůstává "+styl); + return true; + } else { + ladici_vypis(LADENI, "styly.vyber", "změna stylu na "+styl); + } + + // Nejdříve povolíme + this.zmen_styl( styl, true ); + + // Potom zakážeme + this.zmen_styl( styl, false ); + + nastav_cookie("styl", styl, 365); + if ( hodnota_cookie("styl") != styl ) { + ladici_vypis(CHYBA, "styly.vyber", "nepodařilo se nastavit cookie"); + } + nastaveni.styl = styl; + return true; +} diff --git a/karel/scripts/styly-tvar.js b/karel/scripts/styly-tvar.js new file mode 100644 index 0000000..16a2583 --- /dev/null +++ b/karel/scripts/styly-tvar.js @@ -0,0 +1,43 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +// JavaScript - základní tvar panelu stylů + +// =========================================================================== +// =~ Vygenerování seznamu stylů ~============================================ + +document.write('
'); + +document.write('
Styl zobrazení'); +for ( var i = 0; i < styly.length; i++ ) { + document.write( + '
'); + + if (ie_hack) { + document.write( + '
'); +} +document.write('
'); + +document.write('
'); diff --git a/karel/scripts/tooltip.js b/karel/scripts/tooltip.js new file mode 100644 index 0000000..24a1019 --- /dev/null +++ b/karel/scripts/tooltip.js @@ -0,0 +1,324 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +// JavaScript - objekt pro zobrazování nástrojových tipů a nápovědy + +// =========================================================================== +// =~ Třída nástrojových tipů ~=============================================== + +// Konstruktor +function Tooltip() +{ + // Prodleva od posledního zobrazení, kdy se tooltip ukáže okamžitě + this.prejeti_mysi = 100; + + // Čas před plným zobrazením tooltipu + this.plne_zobrazeni = 500; + + // Objekt, nad kterým je myš + this.objekt = null; + + // Informace použitá pro jednoznačné rozpoznání objektu (např. #id) + this.info = null; + + // Detaily k objektu, jako je např. obsah tooltipu + this.detail = null; + + // Tooltip je momentálně zobrazen + this.zobrazen = false; + + // Čas ukrytí tooltipu + this.cas_skryti = null; + + // Časovač spuštěný před prvním zobrazením + this.casovac_zobrazeni = null; + + // Objekt tooltipu, jehož obsah se obnovuje při každém zobrazení tooltipu + this.tooltip = null; +} + +// Myš je nad objektem - zobraz tooltip, pokud to je nutné +Tooltip.prototype.pres = function (objekt, info, detail) +{ + // - Pokud nezobrazuji tooltip, zavolej this.pryc + // - Jinak: + // * Když nebyl tooltip nikdy zobrazen, spusť časovač. Časovač spusť, i když + // je doba od posledního skrytí větší, než nastavení. Restartuj časovač, + // pokud objekt není ten samý a časovač už byl spuštěn. + // * Když je tooltip skryt a čas od posledního skrytí je menší, než + // nastavení, zobraz tooltip. + + if ( ! this.muzu_zobrazit(info, detail) ) { + ladici_vypis(LADENI, "tooltip.pres", info, "nezobrazuji"); + this.pryc(objekt, info, detail); + } else { + var cas = new Date(); + var rozdil_casu; + if ( this.cas_skryti ) { + rozdil_casu = cas-this.cas_skryti; + } else { + rozdil_casu = 0; + } + if ( this.cas_skryti == null || + this.cas_skryti && rozdil_casu >= this.prejeti_mysi || + !jsou_shodne(info, this.info) && this.casovac_zobrazeni + ) { + this.objekt = objekt; + this.info = info; + this.detail = detail; + this.zastav_zobrazovani(info, detail); + + var tento_objekt = this; + this.casovac_zobrazeni = setInterval( + function() { tento_objekt.zobraz(objekt, info, detail); }, + this.plne_zobrazeni + ); + + ladici_vypis(LADENI, "tooltip.pres", info, "nastavení časovače na "+ + this.plne_zobrazeni+"ms"); + } else if ( this.cas_skryti && rozdil_casu < this.prejeti_mysi ) { + this.zobraz(objekt, info, detail); + } else { + ladici_vypis(LADENI, "tooltip.pres", info, "žádná změna"); + } + } +} + +// Myš opustila objekt - skryj tooltip, pokud to je potřeba +Tooltip.prototype.pryc = function (objekt, info, detail) +{ + // Pokud byl nastaven časovač, ale tooltip ještě nebyl zobrazen, zastav + // zobrazování. Pokud už byl zobrazen stejný objekt, skryj ho. + var shodne = jsou_shodne(info, this.info); + if ( this.casovac_zobrazeni || shodne ) { + if ( shodne ) { + ladici_vypis(LADENI, "tooltip.pryc", info, "myš úplně opustila tooltip"); + this.objekt = null; + this.info = null; + this.detail = null; + this.skryj(objekt, info, detail); + } + this.zastav_zobrazovani(info, detail); + } else { + ladici_vypis(LADENI, "tooltip.pryc", info, "žádná změna"); + } +} + +Tooltip.prototype.zrus = function (objekt, info, detail) +{ + // Skryj tooltip + ladici_vypis(LADENI, "tooltip.zrus", info, "zrušení tooltipu"); + this.skryj(objekt, info, detail); + this.cas_skryti = null; +} + +// Zastav zobrazování +Tooltip.prototype.zastav_zobrazovani = function (info, detail) +{ + if ( this.casovac_zobrazeni ) { + ladici_vypis(LADENI, "tooltip.zastav_zobrazovani", info, "zrušení časovače"); + clearInterval( this.casovac_zobrazeni ); + this.casovac_zobrazeni = null; + } +} + +// Skryj tooltip +Tooltip.prototype.skryj = function (objekt, info, detail) +{ + this.zastav_zobrazovani(info, detail); + ladici_vypis(LADENI, "tooltip.skryj", info, "skrytí tooltipu"); + if ( this.zobrazen ) { + if ( this.tooltip ) { + this.tooltip.style.display = "none"; + this.tooltip.style.visibility = "hidden"; + } + this.cas_skryti = new Date(); + } + this.zobrazen = false; +} + +// Zobraz tooltip +Tooltip.prototype.zobraz = function (objekt, info, detail) +{ + this.objekt = objekt; + this.info = info; + this.detail = detail; + this.zastav_zobrazovani(info, detail); + this.zobrazen = true; + + if ( ! this.tooltip ) this.tooltip = this.vytvor(info, detail); + if ( this.tooltip ) { + this.tooltip.style.zIndex = -1; + this.tooltip.style.left = this.tooltip.style.top = "0"; + this.tooltip.style.visibility = "hidden"; + this.tooltip.style.display = "block"; + + this.obnov(this.tooltip, info, detail); + this.pozicuj(this.tooltip, objekt, info, detail); + + this.tooltip.style.display = "block"; + this.tooltip.style.zIndex = 1; + this.tooltip.style.visibility = "visible"; + } + + ladici_vypis(LADENI, "tooltip.zobraz", info, "zobrazení tooltipu"); +} + +// Změň pozici tooltipu +Tooltip.prototype.pozicuj = function (tooltip, objekt, info, detail) +{ + this.uprav_rozmery(tooltip); + + var rozmery = this.vypocti_pozici(tooltip, objekt, true); + if ( ! rozmery.uspech ) { + var nove_rozmery = + this.vypocti_pozici(tooltip, objekt, false); + if ( nove_rozmery.uspech ) { + rozmery = nove_rozmery; + } + } + + tooltip.style.left = rozmery.levy+"px"; + tooltip.style.top = rozmery.horni+"px"; +} + +// Vypočti pozici tooltipu +Tooltip.prototype.vypocti_pozici = function (tooltip, objekt, dole) +{ + var rozmery_objektu = this.zjisti_rozmery(objekt); + ladici_vypis(LADENI, "tooltip.vypocti_pozici", rozmery_objektu, "objekt"); + + var rozmery = zjisti_rozmery(); + + var tooltip_velikost = zjisti_velikost(tooltip.element_tooltip); + + var tooltip_rozmery = { + levy: rozmery_objektu.levy, + pravy: rozmery_objektu.levy + tooltip_velikost.x + }; + + if ( dole ) { + tooltip_rozmery.horni = rozmery_objektu.dolni; + tooltip_rozmery.dolni = rozmery_objektu.dolni + tooltip_velikost.y; + } else { + tooltip_rozmery.horni = rozmery_objektu.horni - tooltip_velikost.y; + tooltip_rozmery.dolni = rozmery_objektu.horni; + } + + /* Pozice X: + * Levá pozice se shoduje s objektem + -> Když pravý okraj přesahuje okno, posuň nadoraz + -> Když levý okraj přesahuje okno, posuň nadoraz + -> Když pravý okraj přesahuje stránku, posuň nadoraz + -> Když levý okraj přesahuje stránku, posuň na nulu + */ + + if ( tooltip_rozmery.pravy > rozmery.okno.pravy ) { + tooltip_rozmery = posun_x( tooltip_rozmery, + rozmery.okno.pravy-tooltip_rozmery.pravy); + } + if ( tooltip_rozmery.levy < rozmery.okno.levy ) { + tooltip_rozmery = posun_x( tooltip_rozmery, + rozmery.okno.levy-tooltip_rozmery.levy); + } + if ( tooltip_rozmery.pravy > rozmery.stranka.pravy ) { + tooltip_rozmery = posun_x( tooltip_rozmery, + rozmery.stranka.pravy-tooltip_rozmery.pravy); + } + if ( tooltip_rozmery.levy < rozmery.stranka.levy ) { + tooltip_rozmery = posun_x( tooltip_rozmery, + rozmery.stranka.levy-tooltip_rozmery.levy); + } + + tooltip_rozmery.uspech = ( + tooltip_rozmery.levy >= rozmery.okno.levy && + tooltip_rozmery.pravy <= rozmery.okno.pravy && + tooltip_rozmery.horni >= rozmery.okno.horni && + tooltip_rozmery.dolni <= rozmery.okno.dolni + ); + + ladici_vypis(LADENI, "tooltip.vypocti_pozici", tooltip_rozmery, + "rozměry tooltipu"); + + return tooltip_rozmery; +} + +// Uprav rozměry tooltipu +Tooltip.prototype.uprav_rozmery = function (tooltip) +{ + // Zjisti aktuální velikosti + var rozmery = zjisti_rozmery(); + + // Šířka maximálně 30% velikosti okna, ale při zmenšení ne méně než 250px, + // ale rozhorně ne více, než jsou rozměry stránky (ať už to znamená cokoliv + // pro IE) + var max; + max = Math.max( 250, Math.floor(0.3*(rozmery.okno.pravy-rozmery.okno.levy))); + max = Math.min( max, rozmery.stranka.pravy-rozmery.stranka.levy ); + + // Největší velikost tooltipu + tooltip.style.width = max+"px"; + + var tooltip_velikost = zjisti_velikost(tooltip.element_tooltip); + tooltip.style.width = tooltip_velikost.x+"px"; +} + +// =========================================================================== +// =~ Veřejně dostupné funkce ~=============================================== + +Tooltip.prototype.prekresli = function () +{ + if ( this.zobrazen ) { + if ( this.tooltip ) { + if ( this.muzu_zobrazit( info, detail ) ) { + ladici_vypis(LADENI, "tooltip.prekresli", info, "překreslení tooltipu"); + this.zobraz( this.objekt, this.info, this.detail ); + } else { + ladici_vypis(LADENI, "tooltip.prekresli", info, + "nemůže být zobrazen, skrývám"); + this.skryj( this.objekt, this.info, this.detail ); + } + } + } +} + +// =========================================================================== +// =~ Veřejně editovatelné funkce ~=========================================== + +// Jestli zobrazit tooltip +Tooltip.prototype.muzu_zobrazit = function (info, detail) +{ + var muzu = ( detail != undefined && detail != null ); + if ( ! muzu ) { + ladici_vypis(LADENI, "tooltip.muzu_zobrazit", info, + "nemůžu zobrazit, detail:"+formatuj_text(detail)); + } + return muzu; +} + +// Zjisti rozměry objektu pro zobrazení tooltipu +Tooltip.prototype.zjisti_rozmery = function (objekt) +{ + return zjisti_rozmery(objekt); +} + +// Obnov obsah tooltipu +Tooltip.prototype.obnov = function (tooltip, info, detail) +{ +} + +// Vytvoř objekt tooltipu +Tooltip.prototype.vytvor = function (info, detail) +{ + var tooltip = tvoric.tooltip(); + var element = document.getElementById('stranka'); + element.insertBefore(tooltip, element.firstChild); + return tooltip; +} diff --git a/karel/scripts/tvorici-funkce.js b/karel/scripts/tvorici-funkce.js new file mode 100644 index 0000000..0da0ec4 --- /dev/null +++ b/karel/scripts/tvorici-funkce.js @@ -0,0 +1,276 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +// JavaScript - tvořicí funkce pro HTML + +// =========================================================================== +// =~ Globální proměnné ~===================================================== + +tvoric = new Object(); + +// =========================================================================== +// =~ Vygenerování nástrojů ~================================================= + +// Vytvoř nové tlačítko zápisem do dokumentu. Všechny parametry jsou řetězce +tvoric.zapis_tlacitko = function (vytvor_mezeru, id, mys, mys_info, mys_detail) +{ + if ( ! vytvor_mezeru ) { + var detail = ''; + if ( mys_detail ) { + detail = ','+mys_detail; + } + document.write('
'+ + '
'+ + '
'+ + '
'); + } else { + document.write('
'+ + '
'); + } +} + +tvoric.nastav_udalosti_mysi = function (element, mys, mys_info, mys_detail) +{ + var detail = ''; + if ( mys_detail ) { + detail = ','+mys_detail; + } + + // Události + element.onmouseover = new Function( "e", + 'return '+mys+'.pres(e,'+mys_info+detail+');' ); + element.onmouseout = new Function( "e", + 'return '+mys+'.pryc(e,'+mys_info+detail+');' ); + element.onmousedown = new Function( "e", + 'return '+mys+'.stisk(e,'+mys_info+detail+');' ); + element.onmouseup = new Function( "e", + 'return '+mys+'.pust(e,'+mys_info+detail+');' ); +} + +tvoric.vytvor_tlacitko = function (vytvor_mezeru, id, mys, mys_info, mys_detail) +{ + if ( ! vytvor_mezeru ) { + // Vytvoř tlačítko + + // Elementy + var element_tlacitko = document.createElement('DIV'); + var element_tlacitko_nastroj = element_tlacitko.cloneNode(false); + var element_tlacitko_ikona = element_tlacitko.cloneNode(false); + var element_tlacitko_maska = element_tlacitko.cloneNode(false); + + // Události + tvoric.nastav_udalosti_mysi(element_tlacitko_maska, mys, + mys_info, mys_detail); + + // Styly + element_tlacitko.className = "tlacitko"; + element_tlacitko_nastroj.className = "tlacitko-nastroj"; + element_tlacitko_ikona.className = "ikona"; + element_tlacitko_ikona.id = id; + element_tlacitko_maska.className = "tlacitko-maska"; + + // Tvar + element_tlacitko_nastroj.appendChild( element_tlacitko_ikona ); + element_tlacitko.appendChild( element_tlacitko_nastroj ); + element_tlacitko.appendChild( element_tlacitko_maska ); + + return element_tlacitko; + } else { + // Vytvoř mezeru + + // Elementy + var element_tlacitko_mezera = document.createElement('DIV'); + var element_nastroje_mezera = element_tlacitko_mezera.cloneNode(false); + + // Styly + element_tlacitko_mezera.className = "tlacitko-mezera"; + element_nastroje_mezera.className = "nastroje-mezera"; + + // Tvar + element_tlacitko_mezera.appendChild(element_nastroje_mezera); + + return element_tlacitko_mezera; + } +} + +tvoric.maska_tlacitka_z_ikony = function (element_ikona) +{ + return element_ikona.parentNode.nextSibling; +} + +// Zvýrazňování tlačítek +tvoric.zvyraznovac = function(id, zvyraznen, stisknut, vybran) +{ + var element = document.getElementById(id); + var parent = element.parentNode; + if ( vybran || stisknut ) + { + parent.className = "tlacitko-dole"; + } else if ( zvyraznen ) { + parent.className = "tlacitko-nahore"; + } else { + parent.className = "tlacitko-nastroj"; + } +} + +// Tvar nástrojových tipů +tvoric.tooltip = function() +{ +/* Struktura tooltipu + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+*/ + + // Elementy + var tooltip_hranice = document.createElement('DIV') + var tooltip = tooltip_hranice.cloneNode(false); + var horni = tooltip.cloneNode(false); + var pixel = tooltip.cloneNode(false); + var margin_5 = tooltip.cloneNode(false); + var margin_3 = tooltip.cloneNode(false); + var margin_2 = tooltip.cloneNode(false); + var margin_1 = tooltip.cloneNode(false); + var stred = tooltip.cloneNode(false); + var ikona = tooltip.cloneNode(false); + var nadpis = tooltip.cloneNode(false); + var popis = tooltip.cloneNode(false); + var vypln = tooltip.cloneNode(false); + var prazdny = tooltip.cloneNode(false); + var spodni = tooltip.cloneNode(false); + + // Styly + tooltip_hranice.className = 'tooltip-hranice'; + tooltip.className = 'tooltip'; + horni.className = 'horni'; + pixel.className = 'pixel'; + margin_5.className = 'margin-5'; + margin_3.className = 'margin-3'; + margin_2.className = 'margin-2'; + margin_1.className = 'margin-1'; + stred.className = 'stred'; + ikona.className = 'ikona'; + nadpis.className = 'nadpis'; + popis.className = 'popis'; + vypln.className = 'vypln'; + spodni.className = 'spodni'; + + // Tvar + tooltip_hranice.appendChild(tooltip); + tooltip.appendChild(horni); + horni.appendChild(margin_5.cloneNode(false)); + horni.lastChild.appendChild(pixel.cloneNode(false)); + horni.appendChild(margin_3.cloneNode(false)); + horni.lastChild.appendChild(margin_2.cloneNode(false)); + horni.lastChild.lastChild.appendChild(pixel.cloneNode(false)); + horni.appendChild(margin_2.cloneNode(false)); + horni.lastChild.appendChild(margin_1.cloneNode(false)); + horni.lastChild.lastChild.appendChild(pixel.cloneNode(false)); + horni.appendChild(margin_1.cloneNode(false)); + horni.lastChild.appendChild(margin_1.cloneNode(false)); + horni.lastChild.lastChild.appendChild(pixel.cloneNode(false)); + horni.appendChild(margin_1.cloneNode(false)); + horni.lastChild.appendChild(margin_1.cloneNode(false)); + horni.lastChild.lastChild.appendChild(pixel.cloneNode(false)); + tooltip.appendChild(stred); + stred.appendChild(vypln.cloneNode(false)); + stred.lastChild.appendChild(prazdny.cloneNode(false)); + stred.appendChild(ikona); + ikona.appendChild(prazdny.cloneNode(false)); + stred.appendChild(nadpis); + nadpis.appendChild(document.createTextNode("")); + stred.appendChild(popis); + popis.appendChild(document.createTextNode("")); + stred.appendChild(vypln); + stred.lastChild.appendChild(prazdny); + tooltip.appendChild(spodni); + spodni.appendChild(margin_1.cloneNode(false)); + spodni.lastChild.appendChild(margin_1.cloneNode(false)); + spodni.lastChild.lastChild.appendChild(pixel.cloneNode(false)); + spodni.appendChild(margin_1.cloneNode(false)); + spodni.lastChild.appendChild(margin_1.cloneNode(false)); + spodni.lastChild.lastChild.appendChild(pixel.cloneNode(false)); + spodni.appendChild(margin_2.cloneNode(false)); + spodni.lastChild.appendChild(margin_1); + spodni.lastChild.lastChild.appendChild(pixel.cloneNode(false)); + spodni.appendChild(margin_3); + spodni.lastChild.appendChild(margin_2); + spodni.lastChild.lastChild.appendChild(pixel.cloneNode(false)); + spodni.appendChild(margin_5); + spodni.lastChild.appendChild(pixel); + + // Některé zvláštní vlastnosti + tooltip_hranice.element_ikona = ikona.firstChild; + tooltip_hranice.element_nadpis = nadpis.firstChild; + tooltip_hranice.element_popis = popis.firstChild; + tooltip_hranice.element_tooltip = tooltip_hranice.firstChild; + + return tooltip_hranice; +} + +// Nastav vlastnosti tooltipu +tvoric.obnov_tooltip = function (tooltip, ikona, nadpis, popis) +{ + if ( ! tooltip ) { + return; + } + + if ( !ikona ) { ikona = ""; } + tooltip.element_ikona.className = ikona; + + if ( !nadpis ) { nadpis = ""; } + tooltip.element_nadpis.nodeValue = nadpis; + + if ( !popis ) { popis = ""; } + tooltip.element_popis.nodeValue = popis; + + // Nastav mezeru mezi nadpisem a popisem + if ( nadpis.length > 0 && popis.length > 0 ) { + tooltip.element_nadpis.parentNode.style.marginBottom = "1em"; + } else { + tooltip.element_nadpis.parentNode.style.marginBottom = "0"; + } + + var margin = "0px"; + if ( ikona.length > 0 ) { + var velikost = zjisti_velikost(tooltip.element_ikona); + margin = (velikost.x+8)+"px"; + } + tooltip.element_nadpis.parentNode.style.marginLeft = margin; + tooltip.element_popis.parentNode.style.marginLeft = margin; +} diff --git a/karel/scripts/velikosti-funkce.js b/karel/scripts/velikosti-funkce.js new file mode 100644 index 0000000..05ec55d --- /dev/null +++ b/karel/scripts/velikosti-funkce.js @@ -0,0 +1,87 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +// JavaScript - funkce pro práci s různými velikostmi Karla + +// =========================================================================== +// =~ Tovární nastavení ~===================================================== + +// Styl nastavený uživatelem +nastaveni.velikost = hodnota_cookie("velikost"); + +// =========================================================================== +// =~ Globální proměnné ~===================================================== + +// Názvy různých velikostí +velikosti = [ + {jmeno: "Normální", trida: "velikost-normalni"}, + {jmeno: "Malý", trida: "velikost-maly"} +]; + +// =========================================================================== +// =~ Základní nastavení ~==================================================== + +if ( nastaveni.velikost == null ) { + nastaveni.velikost = velikosti[0].jmeno; +} + +// =========================================================================== +// =~ Základní funkce pro práci se styly ~==================================== + +velikosti.zmen_velikost = function(velikost) +{ +} + +// Vyber styl po puštění klávesy +velikosti.vyber_klavesou = function() +{ + var velikost; + ladici_vypis(LADENI, "velikosti.vyber_klavesou", "hledám vybranou velikost"); + for ( var i = 0; i < velikosti.length; i++ ) { + var element = document.getElementById('velikost-'+i); + if ( element && element.checked ) { + velikost = velikosti[i].jmeno; + ladici_vypis(LADENI, "velikosti.vyber_klavesou", "nalezena velikost "+velikost); + } + } + + if ( !velikost ) { + ladici_vypis(CHYBA, "velikost.vyber_klavesou", "nenalezena vybraná velikost"); + return false; + } else { + this.vyber(velikost); + } +} + +// Vyber styl +velikosti.vyber = function(velikost) +{ + if ( velikost == nastaveni.velikost ) { + ladici_vypis(LADENI, "velikost.vyber", "žádná změna velikosti, zůstává "+velikost); + return true; + } else { + ladici_vypis(LADENI, "velikost.vyber", "změna velikosti na "+velikost); + } + + // Nejdříve povolíme + this.zmen_velikost( velikost ); + + nastav_cookie("velikost", velikost, 365); + if ( hodnota_cookie("velikost") != velikost ) { + ladici_vypis(CHYBA, "velikosti.vyber", "nepodařilo se nastavit cookie"); + } + nastaveni.velikost = velikost; + return true; +} + +// =========================================================================== +// =~ Aktivuj správnou velikost ~============================================= + +velikosti.zmen_velikost(nastaveni.velikost); diff --git a/karel/style/format-prikladu.css b/karel/style/format-prikladu.css new file mode 100644 index 0000000..d576b9e --- /dev/null +++ b/karel/style/format-prikladu.css @@ -0,0 +1,66 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +body, code { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11pt; +} + +/* Formát příkazů */ + +.prikaz, .podminka, .novy, .cyklus { + font-weight: bold; +} + +.parametr { + color: black; + background-color: inherit; + font-style: italic; +} + +.prikaz { + color: rgb(100%, 12%, 12%); + background-color: inherit; +} + +.podminka { + color: rgb(12%, 12%, 100%); + background-color: inherit; +} + +.novy { + color: rgb(72%, 72%, 0%); + background-color: inherit; +} + +.cyklus { + color: rgb(0%, 61%, 0%); + background-color: inherit; +} + +.uroven-1 { + margin-left: 2em; +} + +.uroven-2 { + margin-left: 4em; +} + +.uroven-3 { +margin-left: 6em; +} + +.uroven-4 { +margin-left: 8em; +} + +.uroven-5 { +margin-left: 10em; +} diff --git a/karel/style/ladici-konzola-ie.css b/karel/style/ladici-konzola-ie.css new file mode 100644 index 0000000..1f1ab9f --- /dev/null +++ b/karel/style/ladici-konzola-ie.css @@ -0,0 +1,46 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Nastavení ladicí konzoly pro IE 5.5 a 6 */ + +.uroven-1 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/uroven-1.png",sizingMethod="image",enabled=true); +} + +.uroven-2 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/uroven-2.png",sizingMethod="image",enabled=true); +} + +.uroven-3 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/uroven-3.png",sizingMethod="image",enabled=true); +} + +.uroven-4 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/uroven-4.png",sizingMethod="image",enabled=true); +} + +.uroven-5 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/uroven-5.png",sizingMethod="image",enabled=true); +} + +.ikona-rozbalit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/konzola-rozbalit.png",sizingMethod="image",enabled=true); +} + +.ikona-sbalit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/konzola-sbalit.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/ladici-konzola.css b/karel/style/ladici-konzola.css new file mode 100644 index 0000000..c3fccd5 --- /dev/null +++ b/karel/style/ladici-konzola.css @@ -0,0 +1,155 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Nastavení ladicí konzoly */ + +.ovladani-ladeni +{ + height: 12px; + width: auto; +} + +.ovladani-ladeni .prvky +{ + float: right; + width: 54px; + height: 12px; + line-height: 12px; +} + +.ovladani-ladeni .prvky .obsah +{ + width: inherit; + height: inherit; + position: relative; +} + +#uroven +{ + position: absolute; + left: 0; + top: 1px; + width: 41px; + height: 10px; + line-height: 10px; + background-repeat: no-repeat; +} + +.uroven-1 { + background-image: url("../images/uroven-1.png"); +} + +.uroven-2 { + background-image: url("../images/uroven-2.png"); +} + +.uroven-3 { + background-image: url("../images/uroven-3.png"); +} + +.uroven-4 { + background-image: url("../images/uroven-4.png"); +} + +.uroven-5 { + background-image: url("../images/uroven-5.png"); +} + +.ovladani-ladeni .popis +{ + margin: 0px 59px 0px 0px; + height: 10px; + line-height: 10px; + font: 10px bold Arial, Helvetica, sans-serif; + text-align: right; + vertical-align: top; + text-align: right; +} + +.ovladani-ladeni .maska { + position: absolute; + top: 0; + width: 41px; + height: 12px; +} + +.ovladani-ladeni .maska div { + float: left; + width: 8px; + height: 12px; +} + +.ovladani-ladeni .maska #uroven-5 { + float: left; + width: 9px; + height: 12px; +} + +#vypis-ikona, .vypis-ikona { + position: absolute; + top: 1px; + left: 42px; + width: 11px; + height: 10px; + line-height: 10px; + background-repeat: no-repeat; +} + +.vypis-ikona { + top: 0; + height: 12px; + line-height: 12px; +} + +.ikona-rozbalit { + background-image: url("../images/konzola-rozbalit.png"); +} + +.ikona-sbalit { + background-image: url("../images/konzola-sbalit.png"); +} + +.konzola { + display: none; + height: 150px; + width: 321px; + background-color: black; +} + +#konzola { + display: block; + margin: 0; + position: relative; + left: 1px; + top: 1px; + background-color: rgb(0%, 100%, 25%); + width: 319px; + height: 148px; + overflow: scroll; +} + +#konzola .radka { + white-space: nowrap; +} + +#konzola .cas { + font-style: italic; +} + +#konzola .funkce { + font-weight: bold; +} + +#konzola .info { + font-style: italic; +} + +#konzola .text { +} diff --git a/karel/style/mesto-kulicky-ie.css b/karel/style/mesto-kulicky-ie.css new file mode 100644 index 0000000..9f3190e --- /dev/null +++ b/karel/style/mesto-kulicky-ie.css @@ -0,0 +1,53 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Barvy a obrázky pro město pro IE 5.5 a 6 */ + +@import url("mesto-normalni-ie.css"); + +.znacka-1 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/kulicky/znacka-1.png",sizingMethod="image",enabled=true); +} + +.znacka-2 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/kulicky/znacka-2.png",sizingMethod="image",enabled=true); +} + +.znacka-3 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/kulicky/znacka-3.png",sizingMethod="image",enabled=true); +} + +.znacka-4 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/kulicky/znacka-4.png",sizingMethod="image",enabled=true); +} + +.znacka-5 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/kulicky/znacka-5.png",sizingMethod="image",enabled=true); +} + +.znacka-6 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/kulicky/znacka-6.png",sizingMethod="image",enabled=true); +} + +.znacka-7 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/kulicky/znacka-7.png",sizingMethod="image",enabled=true); +} + +.znacka-8 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/kulicky/znacka-8.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/mesto-kulicky.css b/karel/style/mesto-kulicky.css new file mode 100644 index 0000000..5aeec6a --- /dev/null +++ b/karel/style/mesto-kulicky.css @@ -0,0 +1,45 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Barvy a obrázky pro město */ + +@import url("mesto-normalni.css"); + +.znacka-1 { + background-image: url("../images/32x32/kulicky/znacka-1.png"); +} + +.znacka-2 { + background-image: url("../images/32x32/kulicky/znacka-2.png"); +} + +.znacka-3 { + background-image: url("../images/32x32/kulicky/znacka-3.png"); +} + +.znacka-4 { + background-image: url("../images/32x32/kulicky/znacka-4.png"); +} + +.znacka-5 { + background-image: url("../images/32x32/kulicky/znacka-5.png"); +} + +.znacka-6 { + background-image: url("../images/32x32/kulicky/znacka-6.png"); +} + +.znacka-7 { + background-image: url("../images/32x32/kulicky/znacka-7.png"); +} + +.znacka-8 { + background-image: url("../images/32x32/kulicky/znacka-8.png"); +} diff --git a/karel/style/mesto-normalni-ie.css b/karel/style/mesto-normalni-ie.css new file mode 100644 index 0000000..6d9bd68 --- /dev/null +++ b/karel/style/mesto-normalni-ie.css @@ -0,0 +1,86 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Barvy a obrázky pro město pro IE 5.5 a 6 */ + +.zed { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/zed.png",sizingMethod="image",enabled=true); +} + +.znacka-1 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-1.png",sizingMethod="image",enabled=true); +} + +.znacka-2 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-2.png",sizingMethod="image",enabled=true); +} + +.znacka-3 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-3.png",sizingMethod="image",enabled=true); +} + +.znacka-4 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-4.png",sizingMethod="image",enabled=true); +} + +.znacka-5 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-5.png",sizingMethod="image",enabled=true); +} + +.znacka-6 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-6.png",sizingMethod="image",enabled=true); +} + +.znacka-7 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-7.png",sizingMethod="image",enabled=true); +} + +.znacka-8 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-8.png",sizingMethod="image",enabled=true); +} + +.karel-vychod { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/karel-vychod.png",sizingMethod="image",enabled=true); +} + +.karel-sever { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/karel-sever.png",sizingMethod="image",enabled=true); +} + +.karel-zapad { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/karel-zapad.png",sizingMethod="image",enabled=true); +} + +.karel-jih { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/karel-jih.png",sizingMethod="image",enabled=true); +} + +.domov { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/domov.png",sizingMethod="image",enabled=true); +} + +.vyber { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/vyber.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/mesto-normalni.css b/karel/style/mesto-normalni.css new file mode 100644 index 0000000..9cac994 --- /dev/null +++ b/karel/style/mesto-normalni.css @@ -0,0 +1,79 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Barvy a obrázky pro město */ + +.linka { + background-color: gray; +} + +.pozadi .policko { + background-color: rgb(69%, 100%, 69%); +} + +.zed { + background-image: url("../images/32x32/normalni/zed.png"); +} + +.znacka-1 { + background-image: url("../images/32x32/normalni/znacka-1.png"); +} + +.znacka-2 { + background-image: url("../images/32x32/normalni/znacka-2.png"); +} + +.znacka-3 { + background-image: url("../images/32x32/normalni/znacka-3.png"); +} + +.znacka-4 { + background-image: url("../images/32x32/normalni/znacka-4.png"); +} + +.znacka-5 { + background-image: url("../images/32x32/normalni/znacka-5.png"); +} + +.znacka-6 { + background-image: url("../images/32x32/normalni/znacka-6.png"); +} + +.znacka-7 { + background-image: url("../images/32x32/normalni/znacka-7.png"); +} + +.znacka-8 { + background-image: url("../images/32x32/normalni/znacka-8.png"); +} + +.karel-vychod { + background-image: url("../images/32x32/normalni/karel-vychod.png"); +} + +.karel-sever { + background-image: url("../images/32x32/normalni/karel-sever.png"); +} + +.karel-zapad { + background-image: url("../images/32x32/normalni/karel-zapad.png"); +} + +.karel-jih { + background-image: url("../images/32x32/normalni/karel-jih.png"); +} + +.domov { + background-image: url("../images/32x32/normalni/domov.png"); +} + +.vyber { + background-image: url("../images/32x32/normalni/vyber.png"); +} diff --git a/karel/style/mesto-obecne.css b/karel/style/mesto-obecne.css new file mode 100644 index 0000000..0007f18 --- /dev/null +++ b/karel/style/mesto-obecne.css @@ -0,0 +1,89 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení města */ + +.mesto { +} + +.mesto .nadpis { + background-color: rgb(50%, 0%, 0%); + color: white; + text-align: center; + font-weight: bold; + font-size: 69%; + border: 1px solid gray; + border-bottom: none; +} + +.mesto .obsah { + display: block; + position: relative; + width: 321px; + height: 321px; + overflow: hidden; +} + +.mesto .linka { + display: block; + position: absolute; + left: 0px; + top: 0px; + width: 321px; + height: 321px; +} + +.mesto .pozadi, .mesto .struktura, .mesto .policko-domov, +.mesto .policko-karel, .mesto .policko-vyber, .mesto .maska { + display: block; + position: absolute; + left: 1px; + top: 1px; + width: 320px; + height: 320px; +} + +.mesto .nastroje { + display: block; + position: absolute; + width: 319px; + top: 321px; + left: 1px; +} + +.mesto .pozadi div, .mesto .struktura div, .mesto .maska div { + float: left; + width: 32px; + height: 32px; +} + +.mesto .pozadi .policko { + display: block; + float: none; + width: 31px; + height: 31px; +} + +.znacka-1, .znacka-2, .znacka-3, .znacka-4, .znacka-5, .znacka-6, +.znacka-7, .znacka-8, .zed { + position: relative; + width: 32px; + height: 32px; +} + +.vyber { + visibility: hidden; +} + +#pozice_domov, #pozice_karel, #pozice_vyber { + position: relative; + width: 32px; + height: 32px; +} diff --git a/karel/style/napoveda-ie.css b/karel/style/napoveda-ie.css new file mode 100644 index 0000000..977c941 --- /dev/null +++ b/karel/style/napoveda-ie.css @@ -0,0 +1,171 @@ +/* +* [Česky] +* Projekt: Robot Karel +* Copyright: Viz KOPIROVANI v kořenovém adresáři projektu +* +* [English] +* Project: Karel, the Robot +* Copyright: See COPYING in the top level directory +*/ + +/* Formátování nápovědy pro IE 5.5 a 6 */ + +.stupnice .ryska { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/stupnice-rychlost.png",sizingMethod="image",enabled=true); +} + +.stupnice .vybrany { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../images/stupnice-ukazatel.png",sizingMethod="image",enabled=true); +} + +.nastroje-mezera { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../images/prikaz-mezera.png",sizingMethod="image",enabled=true); +} + +.nastroje-karel { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-karel.png",sizingMethod="image",enabled=true); +} + +.nastroje-domov { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-domov.png",sizingMethod="image",enabled=true); +} + +.nastroje-smaz-vse { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-smaz-vse.png",sizingMethod="image",enabled=true); +} + +.nastroje-smaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/normalni/prikaz-smaz.png",sizingMethod="image",enabled=true); +} + +.nastroje-zed { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-zed.png",sizingMethod="image",enabled=true); +} + +.nastroje-znacka-minus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/normalni/prikaz-znacka-minus.png",sizingMethod="image",enabled=true); +} + +.nastroje-znacka-plus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/normalni/prikaz-znacka-plus.png",sizingMethod="image",enabled=true); +} + +.nastroje-nacist { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-nacist.png",sizingMethod="image",enabled=true); +} + +.nastroje-ulozit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-uloz.png",sizingMethod="image",enabled=true); +} + +.nastroje-exportovat-k99 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-export-k99.png",sizingMethod="image",enabled=true); +} + +.spustit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-spustit.png",sizingMethod="image",enabled=true); +} + +.zastavit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-zastavit.png",sizingMethod="image",enabled=true); +} + +.slovnik-zobraz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-zobrazit.png",sizingMethod="image",enabled=true); +} + +.slovnik-smaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-smaz-prikaz.png",sizingMethod="image",enabled=true); +} + +.slovnik-smaz-vse { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-smaz-vse.png",sizingMethod="image",enabled=true); +} + +.slovnik-nacist { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-nacist.png",sizingMethod="image",enabled=true); +} + +.slovnik-ulozit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-uloz.png",sizingMethod="image",enabled=true); +} + +.slovnik-exportovat-k99 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-export-k99.png",sizingMethod="image",enabled=true); +} + +.slovnik-exportovat-12 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-export-1.2.png",sizingMethod="image",enabled=true); +} + +.editor-novy { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-novy-prikaz.png",sizingMethod="image",enabled=true); +} + +.editor-ulozit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-uloz-prikaz.png",sizingMethod="image",enabled=true); +} + +.editor-ulozit-jako { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-uloz-prikaz-nove.png",sizingMethod="image",enabled=true); +} + +.karel-vychod { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/karel-vychod.png",sizingMethod="image",enabled=true); +} + +.karel-sever { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/karel-sever.png",sizingMethod="image",enabled=true); +} + +.karel-zapad { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/karel-zapad.png",sizingMethod="image",enabled=true); +} + +.karel-jih { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/karel-jih.png",sizingMethod="image",enabled=true); +} + +.domov { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/domov.png",sizingMethod="image",enabled=true); +} + +.zed { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/zed.png",sizingMethod="image",enabled=true); +} + +.znacka-1 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/32x32/normalni/znacka-1.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/napoveda.css b/karel/style/napoveda.css new file mode 100644 index 0000000..9baae67 --- /dev/null +++ b/karel/style/napoveda.css @@ -0,0 +1,404 @@ +/* +* [Česky] +* Projekt: Robot Karel +* Copyright: Viz KOPIROVANI v kořenovém adresáři projektu +* +* [English] +* Project: Karel, the Robot +* Copyright: See COPYING in the top level directory +*/ + +/* Formátování nápovědy */ + +/* Obecné formátování prvků */ + +body, code { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11pt; +} + +ul { + list-style-type: disc; +} + +code { + white-space: nowrap; +} + +.hlavni { + margin-left: 2em; margin-right: 2em; +} + +.karel { + float: left; margin-right: 5px; +} + +.navigace { + float: left; + padding: 5px; + border: 2px solid rgb(70%, 70%, 70%); + background-color: rgb(90%, 95%, 90%); + color: inherit; + margin-right: 10px; +} + +.navigace a { + display: block; +} + +.vpravo { + text-align: right; +} + +.centruj { + text-align: center; +} + +.stred-vlevo { + vertical-align: middle; +} + +.stred { + vertical-align: middle; + text-align: center; +} + +h1 { + font-size: 144%; +} + +h2 { + font-size: 120%; +} + +.mezery { + white-space: nowrap; +} + +/* Tabulky */ + +table { + margin-left: 3em; + border-collapse: collapse; + margin-top: 1em; + margin-bottom: 1em; + empty-cells: hide; +} + +td { + padding-left: 0.7em; + padding-right: 0.7em; + empty-cells: show; +} + +td p { + margin-bottom: 0; +} + +td p:first-child { + margin-top: 0; +} + +tr { + vertical-align: top; +} + +td { + border: 1px solid rgb(80%, 85%, 80%); +} + +.licha td, tr td.licha { + background-color: rgb(90%, 100%, 90%); + color:inherit; + padding-bottom: 0.5em; + padding-top: 0.5em; +} + +.suda td, tr td.suda { + background-color: rgb(93%, 93%, 93%); + color:inherit; + padding-bottom: 0.5em; + padding-top: 0.5em; +} + + +/* Toolbar a ikony */ + +.podminky .obrazek div, .ikony .obrazek div, .pozadi { + background-color: rgb(69%, 100%, 69%); + color: inherit; + margin-top: 3px; + margin-bottom: 3px; +} + +.pozadi { + width: 32px; + height: 32px; +} + +.toolbar { + background-color: rgb(75%, 75%, 75%); + color: inherit; +} + +.toolbar-mesto { + width: 144px; + height: 20px; +} + +.toolbar-slovnik { + width: 64px; + height: 20px; +} + +.toolbar-slovnik-nacist { + width: 84px; + height: 20px; +} + +.toolbar-mesto-nacist { + width: 60px; + height: 20px; +} + +.tlacitko, .tlacitko-mezera, .ikona { + height: 20px; +} + +.tlacitko { + width: 20px; + float: left; +} + +.tlacitko-mezera { + width: 4px; + float: left; +} + +.obrazek, .ikona { + width: auto; + text-align: center; +} + +.obrazek div { + width: 32px; + height: 32px; + margin-left: auto; + margin-right: auto; +} + +.ikona div { + position: relative; + top: 2px; + width: 16px; + height: 16px; + margin-left: auto; + margin-right: auto; +} + +.tlacitko div { + position: relative; + top: 2px; + left: 2px; + height: 16px; + width: 16px; + background-repeat: no-repeat; +} + +.tlacitko-mezera div { + position: relative; + background-repeat: no-repeat; + top: 1px; + left: 2px; + width: 2px; + height: 18px; +} + +.tooltip { + width: auto; + text-align: center; + white-space: nowrap; + font-size: 83%; + font-weight: bold; +} + +/* Stupnice */ + +.stupnice { + width: auto; + height: auto; + padding-left: 4px; + padding-right: 4px; + padding-top: 4px; +} + +.stupnice .ryska-oblast { + width: 299px; + height: 24px; + position: relative; +} + +.stupnice .ryska { + position: absolute; + width: 299px; + height: 12px; + top: 6px; + background-image: url("../images/stupnice-rychlost.png"); + background-position: center; + background-repeat: no-repeat; +} + +.stupnice .vybrany { + width: 23px; + height: 22px; + position: absolute; + left: 138px; + top: 1px; + background-image: url("../../images/stupnice-ukazatel.png"); + background-position: center; + background-repeat: no-repeat; +} + +.stupnice .pomalu, +.stupnice .stredne, +.stupnice .rychle { + font-size: 67%; + font-weight: normal; + height: 15px; + width: auto; + text-align: center; +} + +.stupnice .pomalu { + float: left; +} + +.stupnice .stredne { + text-align: center; +} + +.stupnice .rychle { + float: right; +} + +/* Obrázky */ + +.nastroje-mezera { + background-image: url("../../images/prikaz-mezera.png"); +} + +.nastroje-karel { + background-image: url("../images/16x16/prikaz-karel.png"); +} + +.nastroje-domov { + background-image: url("../images/16x16/prikaz-domov.png"); +} + +.nastroje-smaz-vse { + background-image: url("../images/16x16/prikaz-smaz-vse.png"); +} + +.nastroje-smaz { + background-image: url("../images/16x16/normalni/prikaz-smaz.png"); +} + +.nastroje-zed { + background-image: url("../images/16x16/prikaz-zed.png"); +} + +.nastroje-znacka-minus { + background-image: url("../images/16x16/normalni/prikaz-znacka-minus.png"); +} + +.nastroje-znacka-plus { + background-image: url("../images/16x16/normalni/prikaz-znacka-plus.png"); +} + +.nastroje-nacist { + background-image: url("../images/16x16/prikaz-nacist.png"); +} + +.nastroje-ulozit { + background-image: url("../images/16x16/prikaz-uloz.png"); +} + +.nastroje-exportovat-k99 { + background-image: url("../images/16x16/prikaz-export-k99.png"); +} + +.spustit { + background-image: url("../images/16x16/prikaz-spustit.png"); +} + +.zastavit { + background-image: url("../images/16x16/prikaz-zastavit.png"); +} + +.slovnik-zobraz { + background-image: url("../images/16x16/prikaz-zobrazit.png"); +} + +.slovnik-smaz { + background-image: url("../images/16x16/prikaz-smaz-prikaz.png"); +} + +.slovnik-smaz-vse { + background-image: url("../images/16x16/prikaz-smaz-vse.png"); +} + +.slovnik-nacist { + background-image: url("../images/16x16/prikaz-nacist.png"); +} + +.slovnik-ulozit { + background-image: url("../images/16x16/prikaz-uloz.png"); +} + +.slovnik-exportovat-k99 { + background-image: url("../images/16x16/prikaz-export-k99.png"); +} + +.slovnik-exportovat-12 { + background-image: url("../images/16x16/prikaz-export-1.2.png"); +} + +.editor-novy { + background-image: url("../images/16x16/prikaz-novy-prikaz.png"); +} + +.editor-ulozit { + background-image: url("../images/16x16/prikaz-uloz-prikaz.png"); +} + +.editor-ulozit-jako { + background-image: url("../images/16x16/prikaz-uloz-prikaz-nove.png"); +} + +.karel-vychod { + background-image: url("../images/32x32/normalni/karel-vychod.png"); +} + +.karel-sever { + background-image: url("../images/32x32/normalni/karel-sever.png"); +} + +.karel-zapad { + background-image: url("../images/32x32/normalni/karel-zapad.png"); +} + +.karel-jih { + background-image: url("../images/32x32/normalni/karel-jih.png"); +} + +.domov { + background-image: url("../images/32x32/normalni/domov.png"); +} + +.zed { + background-image: url("../images/32x32/normalni/zed.png"); +} + +.znacka-1 { + background-image: url("../images/32x32/normalni/znacka-1.png"); +} diff --git a/karel/style/nastaveni-ie.css b/karel/style/nastaveni-ie.css new file mode 100644 index 0000000..5e6825c --- /dev/null +++ b/karel/style/nastaveni-ie.css @@ -0,0 +1,26 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Nastavení zobrazení nastavení pro IE 5.5 a 6 */ + +.nastaveni-prodleva .stupnice .duha { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/stupnice-rychlost.png",sizingMethod="image",enabled=true); +} + +.nastaveni-prodleva .ukazatel .vybrany { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/stupnice-ukazatel.png",sizingMethod="image",enabled=true); +} + +.nastaveni-prodleva .ukazatel .zvyrazneny { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/stupnice-ukazatel-zvyrazneny.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/nastaveni.css b/karel/style/nastaveni.css new file mode 100644 index 0000000..8a7aa43 --- /dev/null +++ b/karel/style/nastaveni.css @@ -0,0 +1,105 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Nastavení zobrazení nastavení */ + +.nastaveni-prodleva { + clear: left; + padding-top: 5px; + width: 321px; + height: auto; +} + +.nastaveni-prodleva .prodleva { + padding: 5px; + font-weight: bold; + border: 1px solid; + border-top-color: rgb(90%, 90%, 90%); + border-left-color: rgb(90%, 90%, 90%); + border-right-color: rgb(40%, 40%, 40%); + border-bottom-color: rgb(40%, 40%, 40%); + background-color: rgb(75%, 75%, 75%); +} + +.nastaveni-prodleva .obsah { + width: 309px; + height: auto; + position: relative; + top: 2px; +} + +.nastaveni-prodleva .stupnice { + width: 309px; + height: 24px; + position: relative; +} + +.nastaveni-prodleva .stupnice .duha { + position: absolute; + top: 6px; + left: 5px; + width: 299px; + height: 12px; + background-image: url("../images/stupnice-rychlost.png"); + background-repeat: no-repeat; +} + +.nastaveni-prodleva .stupnice .ukazatel { + position: absolute; + top: 1px; + left: 5px; + width: 299px; + height: 22px; +} + +.nastaveni-prodleva .stupnice .maska { + position: absolute; + top: 1px; + left: 5px; + width: 299px; + height: 22px; +} + +.nastaveni-prodleva .stupnice .ukazatel .vybrany, +.nastaveni-prodleva .stupnice .ukazatel .zvyrazneny, +.nastaveni-prodleva .stupnice .ukazatel .nic, +.nastaveni-prodleva .stupnice .maska div { + float: left; + width: 23px; + height: 22px; +} + +.nastaveni-prodleva .ukazatel .vybrany { + background-image: url("../images/stupnice-ukazatel.png"); +} + +.nastaveni-prodleva .ukazatel .zvyrazneny { + background-image: url("../images/stupnice-ukazatel-zvyrazneny.png"); +} + +.nastaveni-prodleva .pomalu, +.nastaveni-prodleva .stredne, +.nastaveni-prodleva .rychle { + font-size: 67%; + font-weight: normal; + height: 15px; +} + +.nastaveni-prodleva .pomalu { + float: left; +} + +.nastaveni-prodleva .stredne { + text-align: center; +} + +.nastaveni-prodleva .rychle { + float: right; +} diff --git a/karel/style/nastroje-kulicky-ie.css b/karel/style/nastroje-kulicky-ie.css new file mode 100644 index 0000000..b19a076 --- /dev/null +++ b/karel/style/nastroje-kulicky-ie.css @@ -0,0 +1,28 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Barvy a obrázky pro nástroje pro IE 5.5 a 6 */ + +@import url("nastroje-normalni-ie.css"); + +#nastroje-smaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/kulicky/prikaz-smaz.png",sizingMethod="image",enabled=true); +} + +#nastroje-znacka-minus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/kulicky/prikaz-znacka-minus.png",sizingMethod="image",enabled=true); +} + +#nastroje-znacka-plus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/kulicky/prikaz-znacka-plus.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/nastroje-kulicky.css b/karel/style/nastroje-kulicky.css new file mode 100644 index 0000000..3bf292a --- /dev/null +++ b/karel/style/nastroje-kulicky.css @@ -0,0 +1,25 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Barvy a obrázky pro nástroje */ + +@import url("nastroje-normalni.css"); + +#nastroje-smaz { + background-image: url("../images/16x16/kulicky/prikaz-smaz.png"); +} + +#nastroje-znacka-minus { + background-image: url("../images/16x16/kulicky/prikaz-znacka-minus.png"); +} + +#nastroje-znacka-plus { + background-image: url("../images/16x16/kulicky/prikaz-znacka-plus.png"); +} diff --git a/karel/style/nastroje-mesto.css b/karel/style/nastroje-mesto.css new file mode 100644 index 0000000..cf03dc3 --- /dev/null +++ b/karel/style/nastroje-mesto.css @@ -0,0 +1,57 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Nastavení nástrojů pro město */ + +.mesto-nastroje { + border-left: 1px solid gray; + border-right: 1px solid gray; + border-bottom: 1px solid gray; + height: 24px; +} + +.mesto-nastroje div#pozice-x, +.mesto-nastroje div#pozice-y, +.mesto-nastroje div.times { + float: left; + padding-top: 2px; + height: 24px; + font: bold 16px Arial, Helvetica, sans-serif; +} + +.mesto-nastroje div#pozice-x { + text-align: right; + width: 31px; +} + +.mesto-nastroje div.times { + text-align: center; + width: 24px; +} + +.mesto-nastroje div#pozice-y { + text-align: left; + width: 32px; +} + +.mesto-nastroje .nastroje { + float: right; + position: relative; + top: 2px; + width: 232px; +} + +.mesto-nastroje .tlacitko { + width: 22px; +} + +.mesto-nastroje .nastroje-mezera { + left: 1px; +} diff --git a/karel/style/nastroje-normalni-ie.css b/karel/style/nastroje-normalni-ie.css new file mode 100644 index 0000000..776ef54 --- /dev/null +++ b/karel/style/nastroje-normalni-ie.css @@ -0,0 +1,61 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Barvy a obrázky pro nástroje pro IE 5.5 a 6 */ + +#nastroje-karel { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-karel.png",sizingMethod="image",enabled=true); +} + +#nastroje-domov { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-domov.png",sizingMethod="image",enabled=true); +} + +#nastroje-smaz-vse { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-smaz-vse.png",sizingMethod="image",enabled=true); +} + +#nastroje-smaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/normalni/prikaz-smaz.png",sizingMethod="image",enabled=true); +} + +#nastroje-zed { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-zed.png",sizingMethod="image",enabled=true); +} + +#nastroje-znacka-minus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/normalni/prikaz-znacka-minus.png",sizingMethod="image",enabled=true); +} + +#nastroje-znacka-plus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/normalni/prikaz-znacka-plus.png",sizingMethod="image",enabled=true); +} + +#nastroje-nacist { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-nacist.png",sizingMethod="image",enabled=true); +} + +#nastroje-ulozit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-uloz.png",sizingMethod="image",enabled=true); +} + +#nastroje-exportovat-k99 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-export-k99.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/nastroje-normalni.css b/karel/style/nastroje-normalni.css new file mode 100644 index 0000000..2511dd8 --- /dev/null +++ b/karel/style/nastroje-normalni.css @@ -0,0 +1,51 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Barvy a obrázky pro nástroje */ + +#nastroje-karel { + background-image: url("../images/16x16/prikaz-karel.png"); +} + +#nastroje-domov { + background-image: url("../images/16x16/prikaz-domov.png"); +} + +#nastroje-smaz-vse { + background-image: url("../images/16x16/prikaz-smaz-vse.png"); +} + +#nastroje-smaz { + background-image: url("../images/16x16/normalni/prikaz-smaz.png"); +} + +#nastroje-zed { + background-image: url("../images/16x16/prikaz-zed.png"); +} + +#nastroje-znacka-minus { + background-image: url("../images/16x16/normalni/prikaz-znacka-minus.png"); +} + +#nastroje-znacka-plus { + background-image: url("../images/16x16/normalni/prikaz-znacka-plus.png"); +} + +#nastroje-nacist { + background-image: url("../images/16x16/prikaz-nacist.png"); +} + +#nastroje-ulozit { + background-image: url("../images/16x16/prikaz-uloz.png"); +} + +#nastroje-exportovat-k99 { + background-image: url("../images/16x16/prikaz-export-k99.png"); +} diff --git a/karel/style/nastroje-obecne-ie.css b/karel/style/nastroje-obecne-ie.css new file mode 100644 index 0000000..e631646 --- /dev/null +++ b/karel/style/nastroje-obecne-ie.css @@ -0,0 +1,26 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení nástrojů pro IE 5.5 a 6 */ + +.tlacitko-dole { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/tlacitko-dole.png",sizingMethod="image",enabled=true); +} + +.tlacitko-nahore { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/tlacitko-nahore.png",sizingMethod="image",enabled=true); +} + +.nastroje-mezera { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/prikaz-mezera.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/nastroje-obecne.css b/karel/style/nastroje-obecne.css new file mode 100644 index 0000000..b7e02d4 --- /dev/null +++ b/karel/style/nastroje-obecne.css @@ -0,0 +1,96 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení nástrojů */ + +.nastroje { + position: relative; + width: auto; + min-height: 20px; + line-height: 20px; +} + +.tlacitko { + float: left; + display: block; + position: relative; + width: 20px; + height: 20px; + line-height: 20px; +} + +.tlacitko-nastroj, +.tlacitko-nahore, +.tlacitko-dole { + display: block; + position: absolute; + background-repeat: no-repeat; + left: 0px; + top: 0px; + width: 20px; + height: 20px; +} + +.tlacitko .ikona { + position: absolute; + left: 1px; + top: 2px; + width: 16px; + height: 16px; + background-repeat: no-repeat; +} + +.tlacitko-dole .ikona { + left: 2px; + top: 3px; +} + +.tlacitko-maska { + display: block; + position: absolute; + left: 0px; + top: 0px; + width: 20px; + height: 20px; +} + +.tlacitko-mezera { + float: left; + display: block; + position: relative; + width: 6px; + height: 20px; + line-height: 20px; +} + +.nastroje-mezera { + position: absolute; + top: 2px; + left: 2px; + width: 2px; + height: 17px; + background-repeat: no-repeat; +} + +.nastroje { + background-color: rgb(75%, 75%, 75%); +} + +.tlacitko-dole { + background-image: url("../images/tlacitko-dole.png"); +} + +.tlacitko-nahore { + background-image: url("../images/tlacitko-nahore.png"); +} + +.nastroje-mezera { + background-image: url("../images/prikaz-mezera.png"); +} diff --git a/karel/style/obecny-styl.css b/karel/style/obecny-styl.css new file mode 100644 index 0000000..3bc5a8d --- /dev/null +++ b/karel/style/obecny-styl.css @@ -0,0 +1,117 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení vývojového prostředí */ + +body { + font-family: Arial, Helvetica, sans-serif; + font-weight: normal; + font-size: 11pt; + cursor: default; + height: auto; + margin: 0; + padding: 0; + min-width: 680px; +} + +#stranka { + z-index: -1; + margin: 0; + padding: 8px; +} + +#stranka #okraj { + z-index: -1; + position: absolute; + width: 0; + height: 0; +} + +#okno1 { + z-index: -1; + position: fixed; + right: 0; + bottom: 0; +} + +#okno2 { + z-index: -1; + position: absolute; + width: 100%; + height: 100%; +} + +form { + margin: 0; + padding: 0; +} + +textarea { + font-family: Courier New, monospace; + font-weight: normal; + font-size: 11pt; + line-height: 120%; +} + +.pravy-sloupec { + float: right; + width: 321px; + height: auto; + padding: 10px; + border: 1px solid; + border-top-color: rgb(90%, 90%, 90%); + border-left-color: rgb(90%, 90%, 90%); + border-right-color: rgb(40%, 40%, 40%); + border-bottom-color: rgb(40%, 40%, 40%); + background-color: rgb(75%, 75%, 75%); +} + +.pravy-sloupec .centrovany { + width: 321px; +} + + +.informace, +.hlavni-sloupec, +.hlavni-sloupec-posledni { + width: auto; + padding: 10px; + margin-right: 350px; + border: 1px solid; + border-top-color: rgb(90%, 90%, 90%); + border-left-color: rgb(90%, 90%, 90%); + border-right-color: rgb(40%, 40%, 40%); + border-bottom-color: rgb(40%, 40%, 40%); + background-color: rgb(75%, 75%, 75%); +} + +.informace, +.hlavni-sloupec { + margin-bottom: 7px; +} + +.informace { + padding-top: 5px; + padding-bottom: 5px; + font-size: 69%; +} + +.informace .levy { + float: left; + margin-right: 0.75em; +} + +.informace .pravy { + text-align: right; +} + +.informace a.pravy { + margin-left: 0.75em; +} \ No newline at end of file diff --git a/karel/style/prikazy-editor-ie.css b/karel/style/prikazy-editor-ie.css new file mode 100644 index 0000000..4bf9edc --- /dev/null +++ b/karel/style/prikazy-editor-ie.css @@ -0,0 +1,26 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení editoru příkazů pro IE 5.5 a 6 */ + +#editor-novy { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-novy-prikaz.png",sizingMethod="image",enabled=true); +} + +#editor-ulozit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-uloz-prikaz.png",sizingMethod="image",enabled=true); +} + +#editor-ulozit-jako { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-uloz-prikaz-nove.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/prikazy-editor.css b/karel/style/prikazy-editor.css new file mode 100644 index 0000000..7396155 --- /dev/null +++ b/karel/style/prikazy-editor.css @@ -0,0 +1,99 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení editoru příkazů */ + +.editor { + display: block; + border: 1px solid; + border-top-color: rgb(90%, 90%, 90%); + border-left-color: rgb(90%, 90%, 90%); + border-right-color: rgb(40%, 40%, 40%); + border-bottom-color: rgb(40%, 40%, 40%); +} + +.editor .nadpis { + background-color: rgb(50%, 0%, 0%); + color: white; + text-align: center; + font-weight: bold; + font-size: 69%; +} + +.zobrazeny { + min-height: 24px; + line-height: 24px; + margin-left: 0.25em; + font-style: italic; +} + +#zobrazeny-prikaz { + white-space: nowrap; + margin-left: 0.25em; + min-height: 24px; + line-height: 24px; + text-align: left; +} + +#zmeneny-prikaz { + font-size: 83%; + padding-left: 0.25em; + line-height: 0; + vertical-align: super; +} + +.editor .ramecek { + background-color: rgb(90%, 90%, 0%); + border: 1px solid; + border-top-color: rgb(40%, 40%, 40%); + border-left-color: rgb(40%, 40%, 40%); + border-bottom-color: rgb(90%, 90%, 90%); + border-right-color: rgb(90%, 90%, 90%); +} + +.editor .ramecek div.textarea { + width: 100%; +} + +.editor #editace { + border: none; + width: 100%; + background-color: rgb(90%, 90%, 0%); +} + +/* Nástroje editoru */ + +.editor .nastroje { + float: right; + padding-top: 2px; + padding-bottom: 2px; + padding-left: 2px; + min-height: 20px; +} + +.editor .nastroje .tlacitko { + width: 22px; +} + +.editor .nastroje-mezera { + left: 1px; +} + +#editor-novy { + background-image: url("../images/16x16/prikaz-novy-prikaz.png"); +} + +#editor-ulozit { + background-image: url("../images/16x16/prikaz-uloz-prikaz.png"); +} + +#editor-ulozit-jako { + background-image: url("../images/16x16/prikaz-uloz-prikaz-nove.png"); +} diff --git a/karel/style/prikazy-slovnik-ie.css b/karel/style/prikazy-slovnik-ie.css new file mode 100644 index 0000000..b844c59 --- /dev/null +++ b/karel/style/prikazy-slovnik-ie.css @@ -0,0 +1,56 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení slovníku pro IE 5.5 a 6 */ + +.spustit .ikona { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-spustit.png",sizingMethod="image",enabled=true); +} + +.zastavit .ikona { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-zastavit.png",sizingMethod="image",enabled=true); +} + +#slovnik-zobraz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-zobrazit.png",sizingMethod="image",enabled=true); +} + +#slovnik-smaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-smaz-prikaz.png",sizingMethod="image",enabled=true); +} + +#slovnik-smaz-vse { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-smaz-vse.png",sizingMethod="image",enabled=true); +} + +#slovnik-nacist { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-nacist.png",sizingMethod="image",enabled=true); +} + +#slovnik-ulozit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-uloz.png",sizingMethod="image",enabled=true); +} + +#slovnik-exportovat-k99 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-export-k99.png",sizingMethod="image",enabled=true); +} + +#slovnik-exportovat-12 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/16x16/prikaz-export-1.2.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/prikazy-slovnik.css b/karel/style/prikazy-slovnik.css new file mode 100644 index 0000000..7910564 --- /dev/null +++ b/karel/style/prikazy-slovnik.css @@ -0,0 +1,181 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení slovníku */ + +.slovnik { + display: block; + border: 1px solid; + border-top-color: rgb(90%, 90%, 90%); + border-left-color: rgb(90%, 90%, 90%); + border-right-color: rgb(40%, 40%, 40%); + border-bottom-color: rgb(40%, 40%, 40%); +} + +.slovnik .nadpis { + background-color: rgb(50%, 0%, 0%); + color: white; + text-align: center; + font-weight: bold; + font-size: 69%; +} + +.slovnik .ramecek { + border: 1px solid; + border-top-color: rgb(40%, 40%, 40%); + border-left-color: rgb(40%, 40%, 40%); + border-bottom-color: rgb(90%, 90%, 90%); + border-right-color: rgb(90%, 90%, 90%); +} + +/* Okno slovníku */ + +.slovnik #zobrazene { + height: 240px; + overflow: scroll; + background-color: rgb(75%, 75%, 75%); +} + +.slovnik .prikaz { + margin-left: 2px; + min-height: 22px; + line-height: 22px; + vertical-align: middle; +} + +.slovnik .tlacitko { + display: block; + float: left; + position: relative; +} + +#zobrazene .tlacitko { + top: 1px; + height: 22px; +} + +.slovnik .nazev-text { + width: 100%; +} + +.slovnik .nazev, +.slovnik .nazev-vybrany, +.slovnik .nazev-zvyrazneny, +.slovnik .nazev-vybrany-zvyrazneny, +.slovnik .nazev-stisknuty, +.slovnik .nazev-vybrany-stisknuty { + margin-left: 24px; + padding-left: 4px; +} + +.slovnik .nazev-vybrany { + background-color: rgb(50%, 70%, 50%); +} + +.slovnik .nazev-zvyrazneny { + background-color: rgb(70%, 70%, 40%); +} + +.slovnik .nazev-vybrany-zvyrazneny { + background-color: rgb(60%, 75%, 60%); +} + +.slovnik .nazev-stisknuty { + background-color: rgb(70%, 85%, 70%); +} + +.slovnik .nazev-vybrany-stisknuty { + background-color: rgb(85%, 85%, 60%); +} + +.spustit .ikona { + background-image: url("../images/16x16/prikaz-spustit.png"); +} + +.zastavit .ikona { + background-image: url("../images/16x16/prikaz-zastavit.png"); +} + +/* Nástroje slovníku */ + +.slovnik .nastroje { + float: right; + padding-top: 2px; + padding-bottom: 2px; + padding-left: 2px; + min-height: 20px; +} + +.slovnik .nastroje .tlacitko { + width: 22px; +} + +.slovnik .nastroje-mezera { + left: 1px; +} + +#slovnik-zobraz { + background-image: url("../images/16x16/prikaz-zobrazit.png"); +} + +#slovnik-smaz { + background-image: url("../images/16x16/prikaz-smaz-prikaz.png"); +} + +#slovnik-smaz-vse { + background-image: url("../images/16x16/prikaz-smaz-vse.png"); +} + +#slovnik-nacist { + background-image: url("../images/16x16/prikaz-nacist.png"); +} + +#slovnik-ulozit { + background-image: url("../images/16x16/prikaz-uloz.png"); +} + +#slovnik-exportovat-k99 { + background-image: url("../images/16x16/prikaz-export-k99.png"); +} + +#slovnik-exportovat-12 { + background-image: url("../images/16x16/prikaz-export-1.2.png"); +} + +/* Vybraný příkaz */ + +.slovnik .vybrany { + min-height: 24px; + line-height: 24px; + margin-left: 0.25em; + font-style: italic; +} + +#vybrany-prikaz { + white-space: nowrap; + margin-left: 0.25em; + min-height: 24px; + line-height: 24px; + text-align: left; +} + +.slovnik .vypln { + clear: left; + width: 100%; + height: 0; + line-height: 0; +} + +/* Kvůli IE */ +.slovnik .vypln div { + float: right; + height: 0; + width: 0; +} diff --git a/karel/style/styly-ie.css b/karel/style/styly-ie.css new file mode 100644 index 0000000..679697d --- /dev/null +++ b/karel/style/styly-ie.css @@ -0,0 +1,55 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení stylů pro IE 5.5 a 6 */ + +.styly label, .velikosti label { + padding-left: 0px; +} + +.styly .ikona, .velikosti .ikona { + position: relative; + width: 16px; + height: 14px; + vertical-align: middle; +} + +.styly .ikona span, .velikosti .ikona span { + width: 16px; + height: 0; +} + +.styly .styl-klasika, .styly .styl-kulicky, +.velikosti .velikost-normalni, .velikosti .velikost-maly { + position: absolute; + left: 0; + width: 14px; + height: 14px; +} + +.styly .styl-klasika { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/styl-klasika.png",sizingMethod="image",enabled=true); +} + +.styly .styl-kulicky { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/styl-kulicky.png",sizingMethod="image",enabled=true); +} + +.velikosti .velikost-normalni { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/velikost-normalni.png",sizingMethod="image",enabled=true); +} + +.velikosti .velikost-maly { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/velikost-maly.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/styly.css b/karel/style/styly.css new file mode 100644 index 0000000..4e149de --- /dev/null +++ b/karel/style/styly.css @@ -0,0 +1,59 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení stylů */ + +.pravy-sloupec form { + margin-bottom: 0; + margin-top: 0; +} + +.styly, .velikosti { + padding: 5px; + margin-top: 5px; + border: 1px solid; + border-top-color: rgb(90%, 90%, 90%); + border-left-color: rgb(90%, 90%, 90%); + border-right-color: rgb(40%, 40%, 40%); + border-bottom-color: rgb(40%, 40%, 40%); + background-color: rgb(75%, 75%, 75%); + font-weight: bold; +} + +.styly div, .velikosti div { + font-weight: normal; + margin-top: 0; +} + +.styly label, .velikosti label { + padding-left: 16px; + background-repeat: no-repeat; + background-position: left; +} + +.styly .styl-klasika { + background-image: url("../images/styl-klasika.png"); +} + +.styly .styl-kulicky { + background-image: url("../images/styl-kulicky.png"); +} + +.velikosti { + float: right; +} + +.velikosti .velikost-normalni { + background-image: url("../images/velikost-normalni.png"); +} + +.velikosti .velikost-maly { + background-image: url("../images/velikost-maly.png"); +} diff --git a/karel/style/tipy-ie.css b/karel/style/tipy-ie.css new file mode 100644 index 0000000..f70098f --- /dev/null +++ b/karel/style/tipy-ie.css @@ -0,0 +1,41 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Obrázky nástrojových tipů */ + +.tip-zobraz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-zobrazit.png",sizingMethod="image",enabled=true); +} + +.tip-smaz-prikaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-smaz-prikaz.png",sizingMethod="image",enabled=true); +} + +.tip-exportovat-12 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-export-1.2.png",sizingMethod="image",enabled=true); +} + +.tip-novy { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-novy-prikaz.png",sizingMethod="image",enabled=true); +} + +.tip-ulozit-prikaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-uloz-prikaz.png",sizingMethod="image",enabled=true); +} + +.tip-ulozit-jako { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-uloz-prikaz-nove.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/tipy-kulicky-ie.css b/karel/style/tipy-kulicky-ie.css new file mode 100644 index 0000000..473fac3 --- /dev/null +++ b/karel/style/tipy-kulicky-ie.css @@ -0,0 +1,28 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Obrázky nástrojových tipů, kuličky */ + +@import url("tipy-normalni-ie.css"); + +.tip-smaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/kulicky/prikaz-smaz.png",sizingMethod="image",enabled=true); +} + +.tip-znacka-minus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/kulicky/prikaz-znacka-minus.png",sizingMethod="image",enabled=true); +} + +.tip-znacka-plus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/kulicky/prikaz-znacka-plus.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/tipy-kulicky.css b/karel/style/tipy-kulicky.css new file mode 100644 index 0000000..c63fcce --- /dev/null +++ b/karel/style/tipy-kulicky.css @@ -0,0 +1,25 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Obrázky nástrojových tipů, kuličky */ + +@import url("tipy-normalni.css"); + +.tip-smaz { + background-image: url("../images/48x48/kulicky/prikaz-smaz.png"); +} + +.tip-znacka-minus { + background-image: url("../images/48x48/kulicky/prikaz-znacka-minus.png"); +} + +.tip-znacka-plus { + background-image: url("../images/48x48/kulicky/prikaz-znacka-plus.png"); +} diff --git a/karel/style/tipy-normalni-ie.css b/karel/style/tipy-normalni-ie.css new file mode 100644 index 0000000..8729f01 --- /dev/null +++ b/karel/style/tipy-normalni-ie.css @@ -0,0 +1,61 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Obrázky nástrojových tipů, klasika */ + +.tip-karel { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-karel.png",sizingMethod="image",enabled=true); +} + +.tip-domov { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-domov.png",sizingMethod="image",enabled=true); +} + +.tip-smaz-vse { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-smaz-vse.png",sizingMethod="image",enabled=true); +} + +.tip-smaz { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/normalni/prikaz-smaz.png",sizingMethod="image",enabled=true); +} + +.tip-zed { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-zed.png",sizingMethod="image",enabled=true); +} + +.tip-znacka-minus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/normalni/prikaz-znacka-minus.png",sizingMethod="image",enabled=true); +} + +.tip-znacka-plus { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/normalni/prikaz-znacka-plus.png",sizingMethod="image",enabled=true); +} + +.tip-nacist { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-nacist.png",sizingMethod="image",enabled=true); +} + +.tip-ulozit { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-uloz.png",sizingMethod="image",enabled=true); +} + +.tip-exportovat-k99 { + background-image: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/48x48/prikaz-export-k99.png",sizingMethod="image",enabled=true); +} diff --git a/karel/style/tipy-normalni.css b/karel/style/tipy-normalni.css new file mode 100644 index 0000000..644ab9e --- /dev/null +++ b/karel/style/tipy-normalni.css @@ -0,0 +1,51 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Obrázky nástrojových tipů, klasika */ + +.tip-karel { + background-image: url("../images/48x48/prikaz-karel.png"); +} + +.tip-domov { + background-image: url("../images/48x48/prikaz-domov.png"); +} + +.tip-smaz-vse { + background-image: url("../images/48x48/prikaz-smaz-vse.png"); +} + +.tip-smaz { + background-image: url("../images/48x48/normalni/prikaz-smaz.png"); +} + +.tip-zed { + background-image: url("../images/48x48/prikaz-zed.png"); +} + +.tip-znacka-minus { + background-image: url("../images/48x48/normalni/prikaz-znacka-minus.png"); +} + +.tip-znacka-plus { + background-image: url("../images/48x48/normalni/prikaz-znacka-plus.png"); +} + +.tip-nacist { + background-image: url("../images/48x48/prikaz-nacist.png"); +} + +.tip-ulozit { + background-image: url("../images/48x48/prikaz-uloz.png"); +} + +.tip-exportovat-k99 { + background-image: url("../images/48x48/prikaz-export-k99.png"); +} diff --git a/karel/style/tipy.css b/karel/style/tipy.css new file mode 100644 index 0000000..4c238f8 --- /dev/null +++ b/karel/style/tipy.css @@ -0,0 +1,42 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Obrázky nástrojových tipů */ + +.tip-zobraz, .tip-smaz-prikaz, .tip-exportovat-12, .tip-novy, .tip-ulozit-prikaz, .tip-ulozit-jako, +.tip-karel, .tip-domov, .tip-smaz-vse, .tip-smaz, .tip-zed, .tip-znacka-minus, .tip-znacka-plus, +.tip-nacist, .tip-ulozit, .tip-exportovat-k99 { + width: 48px; + height: 48px; +} + +.tip-zobraz { + background-image: url("../images/48x48/prikaz-zobrazit.png"); +} + +.tip-smaz-prikaz { + background-image: url("../images/48x48/prikaz-smaz-prikaz.png"); +} + +.tip-exportovat-12 { + background-image: url("../images/48x48/prikaz-export-1.2.png"); +} + +.tip-novy { + background-image: url("../images/48x48/prikaz-novy-prikaz.png"); +} + +.tip-ulozit-prikaz { + background-image: url("../images/48x48/prikaz-uloz-prikaz.png"); +} + +.tip-ulozit-jako { + background-image: url("../images/48x48/prikaz-uloz-prikaz-nove.png"); +} diff --git a/karel/style/tooltip.css b/karel/style/tooltip.css new file mode 100644 index 0000000..0721a60 --- /dev/null +++ b/karel/style/tooltip.css @@ -0,0 +1,104 @@ +/* + * [Česky] + * Projekt: Robot Karel + * Copyright: Viz KOPIROVANI v kořenovém adresáři projektu + * + * [English] + * Project: Karel, the Robot + * Copyright: See COPYING in the top level directory + */ + +/* Základní nastavení nástrojových tipů */ + +.tooltip-hranice { + display: none; + visibility: hidden; + position: absolute; + left: 0; + top: 0; + margin: 0; + padding: 0; + width: 0; + height: 0; +} + +.tooltip { + float: left; + font-size: 91%; +} + +.tooltip .horni div { + background-color: black; +} + +.tooltip .stred { + display: block; + background-color: rgb(95%, 100%, 80%); + border-left: 1px solid black; + border-right: 1px solid black; + padding-left: 6px; + padding-right: 6px; +} + +.tooltip .ikona { + float: left; +} + +.tooltip .nadpis { + position: relative; + font-weight: bold; + margin-bottom: 1em; + margin-left: 40px; +} + +.tooltip .popis { + position: relative; + margin-left: 40px; +} + +.tooltip .spodni div { + background-color: black; +} + +.tooltip .vypln { + clear: left; + height: 1px; + line-height: 1px; + width: 0; +} + +.tooltip .horni div div, +.tooltip .spodni div div { + background-color: rgb(95%, 100%, 80%); +} + +.tooltip .margin-1 { + margin-left: 1px; + margin-right: 1px; +} + +.tooltip .margin-2 { + margin-left: 2px; + margin-right: 2px; +} + +.tooltip .margin-3 { + margin-left: 3px; + margin-right: 3px; +} + +.tooltip .margin-4 { + margin-left: 4px; + margin-right: 4px; +} + +.tooltip .margin-5 { + margin-left: 5px; + margin-right: 5px; +} + +.tooltip .pixel { + overflow: hidden; + height: 1px; + width: 0; +} diff --git a/lego/boost_navody/17101_A_AutoBuilder.pdf b/lego/boost_navody/17101_A_AutoBuilder.pdf new file mode 100644 index 0000000..eb998c6 Binary files /dev/null and b/lego/boost_navody/17101_A_AutoBuilder.pdf differ diff --git a/lego/boost_navody/17101_A_Frankie_the_Cat.pdf b/lego/boost_navody/17101_A_Frankie_the_Cat.pdf new file mode 100644 index 0000000..47a5dd1 Binary files /dev/null and b/lego/boost_navody/17101_A_Frankie_the_Cat.pdf differ diff --git a/lego/boost_navody/17101_A_Guitar4000.pdf b/lego/boost_navody/17101_A_Guitar4000.pdf new file mode 100644 index 0000000..fc2affc Binary files /dev/null and b/lego/boost_navody/17101_A_Guitar4000.pdf differ diff --git a/lego/boost_navody/17101_A_M.T.R._4.pdf b/lego/boost_navody/17101_A_M.T.R._4.pdf new file mode 100644 index 0000000..e5adef4 Binary files /dev/null and b/lego/boost_navody/17101_A_M.T.R._4.pdf differ diff --git a/lego/boost_navody/17101_A_Vernie_the_Robot.pdf b/lego/boost_navody/17101_A_Vernie_the_Robot.pdf new file mode 100644 index 0000000..34476a6 Binary files /dev/null and b/lego/boost_navody/17101_A_Vernie_the_Robot.pdf differ diff --git a/lego/boost_navody/LEGO_BOOST_Steam_Train_education.pdf b/lego/boost_navody/LEGO_BOOST_Steam_Train_education.pdf new file mode 100644 index 0000000..684142d Binary files /dev/null and b/lego/boost_navody/LEGO_BOOST_Steam_Train_education.pdf differ diff --git a/lego/boost_navody/johnny-5-moc-instructions2.pdf b/lego/boost_navody/johnny-5-moc-instructions2.pdf new file mode 100644 index 0000000..678f0e2 Binary files /dev/null and b/lego/boost_navody/johnny-5-moc-instructions2.pdf differ diff --git a/lego/ev3_user_guide.pdf b/lego/ev3_user_guide.pdf new file mode 100644 index 0000000..e2741e7 Binary files /dev/null and b/lego/ev3_user_guide.pdf differ diff --git a/lego/mindstorms_home_dilky.pdf b/lego/mindstorms_home_dilky.pdf new file mode 100644 index 0000000..490b10c Binary files /dev/null and b/lego/mindstorms_home_dilky.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_BANNER_PRINT3R.pdf b/lego/mindstorms_home_navody/31313_X_BANNER_PRINT3R.pdf new file mode 100644 index 0000000..44563ed Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_BANNER_PRINT3R.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_BOBB3E.pdf b/lego/mindstorms_home_navody/31313_X_BOBB3E.pdf new file mode 100644 index 0000000..f72e4d1 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_BOBB3E.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_DINOREX.pdf b/lego/mindstorms_home_navody/31313_X_DINOREX.pdf new file mode 100644 index 0000000..96930c4 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_DINOREX.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_EL3CTRIC_GUITAR.pdf b/lego/mindstorms_home_navody/31313_X_EL3CTRIC_GUITAR.pdf new file mode 100644 index 0000000..81acaa3 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_EL3CTRIC_GUITAR.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_EV3D4.pdf b/lego/mindstorms_home_navody/31313_X_EV3D4.pdf new file mode 100644 index 0000000..7171660 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_EV3D4.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_EV3MEG.pdf b/lego/mindstorms_home_navody/31313_X_EV3MEG.pdf new file mode 100644 index 0000000..edf02a1 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_EV3MEG.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_EV3RSTORM.pdf b/lego/mindstorms_home_navody/31313_X_EV3RSTORM.pdf new file mode 100644 index 0000000..a25d552 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_EV3RSTORM.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_EV3_GAME.pdf b/lego/mindstorms_home_navody/31313_X_EV3_GAME.pdf new file mode 100644 index 0000000..b5d94d4 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_EV3_GAME.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_GRIPP3R.pdf b/lego/mindstorms_home_navody/31313_X_GRIPP3R.pdf new file mode 100644 index 0000000..4557eb0 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_GRIPP3R.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_KRAZ3.pdf b/lego/mindstorms_home_navody/31313_X_KRAZ3.pdf new file mode 100644 index 0000000..80db520 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_KRAZ3.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_MR_B3AM.pdf b/lego/mindstorms_home_navody/31313_X_MR_B3AM.pdf new file mode 100644 index 0000000..127f680 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_MR_B3AM.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_R3PTAR.pdf b/lego/mindstorms_home_navody/31313_X_R3PTAR.pdf new file mode 100644 index 0000000..fbe5226 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_R3PTAR.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_RAC3_TRUCK.pdf b/lego/mindstorms_home_navody/31313_X_RAC3_TRUCK.pdf new file mode 100644 index 0000000..f2485e1 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_RAC3_TRUCK.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_ROBODOZ3R.pdf b/lego/mindstorms_home_navody/31313_X_ROBODOZ3R.pdf new file mode 100644 index 0000000..3d5e6f8 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_ROBODOZ3R.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_SPIK3R.pdf b/lego/mindstorms_home_navody/31313_X_SPIK3R.pdf new file mode 100644 index 0000000..64df984 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_SPIK3R.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_TRACK3R.pdf b/lego/mindstorms_home_navody/31313_X_TRACK3R.pdf new file mode 100644 index 0000000..9678f71 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_TRACK3R.pdf differ diff --git a/lego/mindstorms_home_navody/31313_X_WACK3M.pdf b/lego/mindstorms_home_navody/31313_X_WACK3M.pdf new file mode 100644 index 0000000..f809610 Binary files /dev/null and b/lego/mindstorms_home_navody/31313_X_WACK3M.pdf differ diff --git a/lego/mindstorms_pluginy_senzory/EnergyMeter.ev3b b/lego/mindstorms_pluginy_senzory/EnergyMeter.ev3b new file mode 100644 index 0000000..ccca623 Binary files /dev/null and b/lego/mindstorms_pluginy_senzory/EnergyMeter.ev3b differ diff --git a/lego/mindstorms_pluginy_senzory/Gyro.ev3b b/lego/mindstorms_pluginy_senzory/Gyro.ev3b new file mode 100644 index 0000000..7b8a233 Binary files /dev/null and b/lego/mindstorms_pluginy_senzory/Gyro.ev3b differ diff --git a/lego/mindstorms_pluginy_senzory/Sound.ev3b b/lego/mindstorms_pluginy_senzory/Sound.ev3b new file mode 100644 index 0000000..3b2288c Binary files /dev/null and b/lego/mindstorms_pluginy_senzory/Sound.ev3b differ diff --git a/lego/mindstorms_pluginy_senzory/Temperature.ev3b b/lego/mindstorms_pluginy_senzory/Temperature.ev3b new file mode 100644 index 0000000..fa3cc1c Binary files /dev/null and b/lego/mindstorms_pluginy_senzory/Temperature.ev3b differ diff --git a/lego/mindstorms_pluginy_senzory/Ultrasonic.ev3b b/lego/mindstorms_pluginy_senzory/Ultrasonic.ev3b new file mode 100644 index 0000000..38c1fc9 Binary files /dev/null and b/lego/mindstorms_pluginy_senzory/Ultrasonic.ev3b differ diff --git a/prezentace/15_patnacta_schuzka.pdf b/prezentace/15_patnacta_schuzka.pdf new file mode 100644 index 0000000..f597641 Binary files /dev/null and b/prezentace/15_patnacta_schuzka.pdf differ diff --git a/zalohy/Strom.ozocode b/zalohy/Strom.ozocode new file mode 100644 index 0000000..a4a5da9 --- /dev/null +++ b/zalohy/Strom.ozocode @@ -0,0 +1 @@ +#ff8000-9030203090304030-9030#00ff002030110301273012730120307030127301273012030703020309030#ff80002030 \ No newline at end of file