naivxnaivet

wow edit ko

Jun 18th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.48 KB | None | 0 0
  1. //Include Libraries
  2. #include <EEPROM.h> //For EEPROM
  3. #include <ESP8266TelnetClient.h> //For ESP Telnet
  4. #include <ESP8266WiFi.h> //For ESP WiFi Core
  5. #include <ESP8266WiFiMulti.h> //For ESP Wifi
  6. #include <LiquidCrystal_I2C.h> //For I2C LCD
  7. #include <Wire.h> //For I2C Communication
  8. #include "Adafruit_Thermal.h" //For thermal printer
  9.  
  10. //----------------------------- ▼ Global Variables ▼ -------------------------------
  11. IPAddress mikrotikRouterIp (192, 168, 22, 1);
  12.  
  13. unsigned long temp;
  14. //WiFi
  15. const char* user = "admin";
  16. const char* pwd = "Secreto#020202";
  17. const char* ssid = "MikroTik Wifi";
  18. const char* password = "Secreto#020202";
  19. String M_command;
  20.  
  21. unsigned long previousMillis = 0; // will store last time LED was updated
  22. const long interval = 10000;
  23. long lcdCoin = 0;
  24. unsigned long previousResetMillis = 0;
  25. bool resetNow = false;
  26.  
  27. unsigned long startTime = 0;
  28. unsigned long checkTime = 0;
  29.  
  30. bool displayCoinCount = false;
  31.  
  32. int dummyCounter = 0;
  33.  
  34. unsigned long debounceDelay = 0;
  35.  
  36. bool activateButton = false;
  37. bool editMode = false;
  38. bool displayMainMessage = true;
  39. bool displayVouch = false;
  40.  
  41. int buttonStateTest1;
  42. int lastButtonStateTest1 = LOW;
  43. unsigned long lastDebounceTimeTest1 = 0;
  44.  
  45. int buttonStateTest2;
  46. int lastButtonStateTest2 = LOW;
  47. unsigned long lastDebounceTimeTest2 = 0;
  48.  
  49. int buttonStateTest3;
  50. int lastButtonStateTest3 = LOW;
  51. unsigned long lastDebounceTimeTest3 = 0;
  52.  
  53. long userCode;
  54.  
  55. int perPisoMin = 5; //ILANG MINUTES
  56. long computation = perPisoMin * 60L;
  57. long hourPromo = 3600UL;
  58.  
  59. long promoComp;
  60. long promoHour = 3600UL;
  61.  
  62. unsigned long promoTime;
  63.  
  64. int counterMap = 0;
  65.  
  66. int counter = 0;
  67. int counterChange = -1;
  68.  
  69. int coins = 0;
  70. int lastCoinCount = 0;
  71. long promoFinal;
  72. long inBet = 0;
  73.  
  74. //Promo Data
  75. //promo prices
  76. int promo1 = 10;
  77. int promo2 = 15;
  78. int promo3 = 20;
  79. int promo4 = 30;
  80. int promo5 = 150;
  81.  
  82. //promo hour
  83. int promoOne = 1;
  84. int promoTwo = 6;
  85. int promoThree = 12;
  86. int promoFour = 24;
  87. int promoFive = 168;
  88.  
  89. //LCD
  90. #define LCD_I2C_ADDR 0x27
  91. #define LCD_ROWS 4
  92. #define LCD_COLS 20
  93.  
  94. //Pinouts
  95. #define buttonPinTest1 D7
  96. #define buttonPinTest2 D3
  97. #define buttonPinTest3 D6
  98. #define LED_BUILTIN D4
  99. #define coinSlotPin D5
  100. #define BACKLIGHT_PIN 13 //backlight pin
  101.  
  102. //EEPROM Settings
  103. #define eeAddressA 0
  104. #define eeAddressB 10
  105. #define eeAddressC 20
  106. #define eeAddressD 30
  107. #define eeAddressE 40
  108. #define eeAddressF 50
  109. #define eeAddressG 60
  110. #define eeAddressH 70
  111. #define eeAddressI 80
  112. #define eeAddressJ 90
  113. #define eeAddressK 100
  114.  
  115. //----------------------------- ▲ Global Variables ▲ -------------------------------
  116.  
  117.  
  118. //----------------------------- ▼ Global Objects ▼ ---------------------------------
  119.  
  120. //ESP WiFi Multi Object
  121. ESP8266WiFiMulti WiFiMulti;
  122.  
  123. //Main ESP WiFi Object
  124. WiFiClient client;
  125.  
  126. //ESP Telnet Object
  127. ESP8266telnetClient tc(client);
  128.  
  129.  
  130. //LCD Object
  131. LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_COLS, LCD_ROWS);
  132.  
  133.  
  134. //thermal
  135.  
  136. Adafruit_Thermal printer(&Serial);
  137. //----------------------------- ▲ Global Objects ▲ ---------------------------------
  138.  
  139. void retrieve_data_from_eeprom() {
  140. EEPROM.get(eeAddressA, promo1);
  141. EEPROM.get(eeAddressB, promoOne);
  142. EEPROM.get(eeAddressC, promo2);
  143. EEPROM.get(eeAddressD, promoTwo);
  144. EEPROM.get(eeAddressE, promo3);
  145. EEPROM.get(eeAddressF, promoThree);
  146. EEPROM.get(eeAddressG, promo4);
  147. EEPROM.get(eeAddressH, promoFour);
  148. EEPROM.get(eeAddressI, promo5);
  149. EEPROM.get(eeAddressJ, promoFive);
  150. EEPROM.get(eeAddressK, perPisoMin);
  151. }
  152.  
  153. ICACHE_RAM_ATTR void coinInserted() {
  154. coins++;
  155.  
  156. if (coins < promo1)
  157. {
  158. promoFinal = computation * coins;
  159. }
  160. else if (coins >= promo1 && coins < promo2)
  161. {
  162. promoTime = promoOne * promoHour;
  163. promoComp = coins - promo1;
  164. inBet = promoComp * computation;
  165. promoFinal = inBet + promoTime;
  166. }
  167. else if (coins >= promo2 && coins < promo3)
  168. {
  169. promoTime = promoTwo * promoHour;
  170. promoComp = coins - promo2;
  171. inBet = promoComp * computation;
  172. promoFinal = inBet + promoTime;
  173. }
  174. else if (coins >= promo3 && coins < promo4)
  175. {
  176. promoTime = promoThree * promoHour;
  177. promoComp = coins - promo3;
  178. inBet = promoComp * computation;
  179. promoFinal = inBet + promoTime;
  180.  
  181. }
  182. else if (coins >= promo4 && coins < promo5)
  183. {
  184. //promo4 = 30;
  185.  
  186. //60 modulo
  187.  
  188. promoTime = promoFour * promoHour;
  189. promoComp = coins - promo4;
  190. inBet = promoComp * computation;
  191. promoFinal = inBet + promoTime;
  192. }
  193. else if (coins >= promo5)
  194. {
  195. promoTime = promoFive * promoHour;
  196. promoComp = coins - promo5;
  197. inBet = promoComp * computation;
  198. promoFinal = inBet + promoTime;
  199. }
  200. //Serial.println(promoFinal);
  201. }
  202.  
  203. void setup() {
  204. //Initialize EEPROM
  205. EEPROM.begin(512);
  206.  
  207.  
  208. //Initialize Serial
  209.  
  210. // //Do Nothing until Serial doesnt get initialized
  211. // while (!Serial) {
  212. // ;
  213. // }
  214.  
  215. //Get Our Saved Promo Data Back
  216. retrieve_data_from_eeprom();
  217.  
  218. computation = perPisoMin * 60L;
  219.  
  220. //coins = 60;
  221. pinMode(coinSlotPin, INPUT);
  222. attachInterrupt(D5, coinInserted, RISING);
  223.  
  224. pinMode(buttonPinTest1, INPUT);
  225. pinMode(buttonPinTest2, INPUT);
  226. pinMode(buttonPinTest3, INPUT);
  227.  
  228. //Initiate the LCD
  229. lcd.begin();
  230. lcd.backlight();
  231.  
  232. lcd.setCursor(5, 0);
  233. lcd.print(F("WELCOME TO"));
  234. lcd.setCursor(0, 1);
  235. lcd.print(F("JHUNDECK HOTSPOT"));
  236. digitalWrite(LED_BUILTIN, HIGH);
  237. delay(1000);
  238.  
  239.  
  240. // Serial.println();
  241. // Serial.println();
  242. // Serial.println("Wait for WI-Fi...");
  243.  
  244.  
  245.  
  246. while (WiFiMulti.run() != WL_CONNECTED)
  247. {
  248. Serial.print(".");
  249. delay(500);
  250. }
  251.  
  252.  
  253.  
  254. //
  255. // Serial.println("");
  256. // Serial.println("WiFi connected");
  257. // Serial.print("IP Address : ");
  258. // Serial.println(WiFi.localIP());
  259. // Serial.println("Connecting....");
  260.  
  261.  
  262. tc.setPromptChar('>');
  263. //manual login pagka may problema
  264. // char key = 0;
  265. // Serial.println("\r\npress enter to begin:");
  266. // do
  267. // {
  268. // key = Serial.read();
  269. // Serial.println(key);
  270. // }
  271. //
  272. // //automatic login
  273. // while (key <= 0);
  274.  
  275. tc.login(mikrotikRouterIp, user, pwd);
  276. printer.sleep();
  277.  
  278.  
  279.  
  280. }
  281.  
  282. void loop() {
  283. editRates();
  284. readBtnTest1();
  285. readBtnTest2();
  286. readBtnTest3();
  287. //Serial.println(counter);
  288. editModeCheck();
  289. displayCheck();
  290. noNegative();
  291. //Serial.println(lcdCoin);
  292. displayCoin();
  293. displayVoucher();
  294. computation = perPisoMin * 60L;
  295. userCode = random(10000, 99999);
  296. //Serial.println(promoFinal);
  297. //Serial.println(counter);
  298. }
  299.  
  300. void readBtnTest1() {
  301. int reading = digitalRead(buttonPinTest1);
  302. if (reading != lastButtonStateTest1) {
  303. lastDebounceTimeTest1 = millis();
  304. }
  305. if ((millis() - lastDebounceTimeTest1) > debounceDelay) {
  306. if (reading != buttonStateTest1) {
  307. buttonStateTest1 = reading;
  308. if (buttonStateTest1 == HIGH)
  309. {
  310. counter++;
  311. }
  312. }
  313. }
  314. lastButtonStateTest1 = reading;
  315. }
  316.  
  317. void readBtnTest2() {
  318. int reading = digitalRead(buttonPinTest2);
  319. if (reading != lastButtonStateTest2) {
  320. lastDebounceTimeTest2 = millis();
  321. }
  322. if ((millis() - lastDebounceTimeTest2) > debounceDelay) {
  323. if (reading != buttonStateTest2) {
  324. buttonStateTest2 = reading;
  325. if (buttonStateTest2 == HIGH)
  326. {
  327. counter--;
  328. }
  329. }
  330. }
  331. lastButtonStateTest2 = reading;
  332. }
  333.  
  334. void readBtnTest3() {
  335. int reading = digitalRead(buttonPinTest3);
  336. if (reading != lastButtonStateTest3) {
  337. lastDebounceTimeTest3 = millis();
  338. }
  339. if ((millis() - lastDebounceTimeTest3) > debounceDelay) {
  340. if (reading != buttonStateTest3) {
  341. buttonStateTest3 = reading;
  342. if (buttonStateTest3 == HIGH)
  343. {
  344. counterChange++;
  345. //Serial.println(counterChange);
  346. }
  347. }
  348. }
  349. lastButtonStateTest3 = reading;
  350. }
  351.  
  352. void booleanCheck() {
  353. if (counter == 5)
  354. {
  355. activateButton = true;
  356. }
  357. }
  358.  
  359. void editModeCheck() {
  360. if (counterChange > 0 && displayMainMessage == true)
  361. {
  362. counterChange = 0;
  363. }
  364.  
  365.  
  366. if (coins > 0)
  367. {
  368. userCode = random(10000, 99999);
  369.  
  370. displayMainMessage = false;
  371. displayCoinCount = true; //map
  372. if (counterChange == 1)
  373. {
  374. printer.sleep();
  375. detachInterrupt(D5);
  376. displayVouch = true;
  377. displayVoucher();
  378. displayVouch = true;
  379. displayCoinCount = false;
  380. resetCountStart();
  381. lcdCoin = coins;
  382. coins = 0;
  383. }
  384.  
  385. }
  386.  
  387. if (displayVouch == true)
  388. {
  389. counterMap = 1;
  390. displayVouch = false;
  391. //Serial.println("Wait reset");
  392. }
  393. if (counterMap == 1 && displayVouch == false)
  394. {
  395. resetAfter(6);
  396. if (resetNow == true && displayCoinCount == false || counterChange == 2)
  397. {
  398.  
  399. lcd.clear();
  400. //Serial.println("Reset ");
  401. resetVariable();
  402. counterMap = 0;
  403. //map666
  404. attachInterrupt(D5, coinInserted, RISING);
  405.  
  406. }
  407. }
  408. }
  409.  
  410. void editRates() {
  411. if (counter == 5 && activateButton == false && dummyCounter == 0)
  412. {
  413. //2242
  414.  
  415. dummyCounter++;
  416. editMode = true;
  417.  
  418. }
  419.  
  420. else if (activateButton == true)
  421. {
  422. lcd.clear();
  423. displayMainMessage = false;
  424. counter = 0;
  425. activateButton = false;
  426. editMode = true;
  427. }
  428.  
  429. if (editMode == true)
  430. {
  431. displayEditMode();
  432.  
  433. displayMainMessage = false;
  434.  
  435. }
  436. }
  437.  
  438. void resetAfter(int sec) {
  439. unsigned long currentResetMillis = millis();
  440. sec *= 1000;
  441. if (currentResetMillis - previousResetMillis >= sec && !resetNow) {
  442. previousResetMillis = currentResetMillis;
  443. resetNow = true;
  444. ////Serial.println("Reset Now");
  445. }
  446. }
  447.  
  448. void resetCountStart() {
  449. unsigned long currentResetMillis = millis();
  450. previousResetMillis = currentResetMillis;
  451. resetNow = false;
  452. }
  453.  
  454. void displayCheck() {
  455. if (displayMainMessage == true)
  456. {
  457. booleanCheck();
  458. //55
  459. lcdCoin = 0;
  460. editMode = false;
  461.  
  462.  
  463. lcd.setCursor(0, 0);
  464. lcd.print(F("Jhundeck Wi-Fi Vendo"));
  465. lcd.setCursor(0, 1);
  466. lcd.print(F(" Promo Price/Hours"));
  467. lcd.setCursor(0, 2);
  468. lcd.print(promo1);
  469. lcd.print(F("/"));
  470. lcd.print(promoOne);
  471. lcd.print(F(" "));
  472.  
  473. lcd.print(promo2);
  474. lcd.print(F("/"));
  475. lcd.print(promoTwo);
  476. lcd.print(F(" "));
  477.  
  478. lcd.print(promo3);
  479. lcd.print(F("/"));
  480. lcd.print(promoThree);
  481. lcd.print(F(" "));
  482.  
  483. lcd.setCursor(0, 3);
  484. lcd.print(promo4);
  485. lcd.print(F("/"));
  486. lcd.print(promoFour);
  487. lcd.print(F(" "));
  488.  
  489.  
  490. lcd.print(promo5);
  491. lcd.print(F("/"));
  492. lcd.print(promoFive);
  493. lcd.print(F(" "));
  494. }
  495. }
  496.  
  497. void displayEditMode() {
  498. if (editMode == true)
  499. {
  500. //write eeprom
  501. if (counterChange == 0)
  502. {
  503. lcd.setCursor(0, 0);
  504. lcd.print(F("EDIT MINUTE PER PISO"));
  505. lcd.setCursor(0, 1);
  506. lcd.print(counter);
  507. lcd.print(F(" "));
  508.  
  509. perPisoMin = counter;
  510. EEPROM.put(eeAddressK, perPisoMin);
  511. EEPROM.commit();
  512. }
  513. else if (counterChange == 1)
  514. {
  515. lcd.setCursor(0, 0);
  516. lcd.print(F(" EDIT PROMO 1 PRICE "));
  517. lcd.setCursor(0, 1);
  518. lcd.print(counter);
  519. lcd.print(F(" "));
  520. promo1 = counter;
  521. EEPROM.put(eeAddressA, promo1);
  522. EEPROM.commit();
  523. }
  524. else if (counterChange == 2)
  525. {
  526. lcd.setCursor(0, 0);
  527. lcd.print(F(" EDIT PROMO 1 HOURS "));
  528. lcd.setCursor(0, 1);
  529. lcd.print(counter);
  530. lcd.print(F(" "));
  531.  
  532. promoOne = counter;
  533. EEPROM.put(eeAddressB, promoOne);
  534. EEPROM.commit();
  535. }
  536. else if (counterChange == 3)
  537. {
  538. lcd.setCursor(0, 0);
  539. lcd.print(F(" EDIT PROMO 2 PRICE "));
  540. lcd.setCursor(0, 1);
  541. lcd.print(counter);
  542. lcd.print(F(" "));
  543.  
  544. promo2 = counter;
  545. EEPROM.put(eeAddressC, promo2);
  546. EEPROM.commit();
  547. }
  548. else if (counterChange == 4)
  549. {
  550. lcd.setCursor(0, 0);
  551. lcd.print(F(" EDIT PROMO 2 HOURS "));
  552. lcd.setCursor(0, 1);
  553. lcd.print(counter);
  554. lcd.print(F(" "));
  555.  
  556. promoTwo = counter;
  557. EEPROM.put(eeAddressD, promoTwo);
  558. EEPROM.commit();
  559. }
  560. else if (counterChange == 5)
  561. {
  562. lcd.setCursor(0, 0);
  563. lcd.print(F( " EDIT PROMO 3 PRICE "));
  564. lcd.setCursor(0, 1);
  565. lcd.print(counter);
  566. lcd.print(F(" "));
  567.  
  568. promo3 = counter;
  569. EEPROM.put(eeAddressE, promo3);
  570. EEPROM.commit();
  571. }
  572. else if (counterChange == 6)
  573. {
  574. lcd.setCursor(0, 0);
  575. lcd.print(F(" EDIT PROMO 3 HOURS "));
  576. lcd.setCursor(0, 1);
  577. lcd.print(counter);
  578. lcd.print(F(" "));
  579.  
  580. promoThree = counter;
  581. EEPROM.put(eeAddressF, promoThree);
  582. EEPROM.commit();
  583. }
  584. else if (counterChange == 7)
  585. {
  586. lcd.setCursor(0, 0);
  587. lcd.print(F(" EDIT PROMO 4 PRICE "));
  588. lcd.setCursor(0, 1);
  589. lcd.print(counter);
  590. lcd.print(F(" "));
  591.  
  592. promo4 = counter;
  593. EEPROM.put(eeAddressG, promo4);
  594. EEPROM.commit();
  595. }
  596. else if (counterChange == 8)
  597. {
  598. lcd.setCursor(0, 0);
  599. lcd.print(F(" EDIT PROMO 4 HOURS "));
  600. lcd.setCursor(0, 1);
  601. lcd.print(counter);
  602. lcd.print(F(" "));
  603.  
  604. promoFour = counter;
  605. EEPROM.put(eeAddressH, promoFour);
  606. EEPROM.commit();
  607. }
  608. else if (counterChange == 9)
  609. {
  610. lcd.setCursor(0, 0);
  611. lcd.print(F(" EDIT PROMO 5 PRICE "));
  612. lcd.setCursor(0, 1);
  613. lcd.print(counter);
  614. lcd.print(F(" "));
  615.  
  616. promo5 = counter;
  617. EEPROM.put(eeAddressI, promo5);
  618. EEPROM.commit();
  619. }
  620. else if (counterChange == 10)
  621. {
  622. lcd.setCursor(0, 0);
  623. lcd.print(F(" EDIT PROMO 5 HOURS "));
  624. lcd.setCursor(0, 1);
  625. lcd.print(counter);
  626. lcd.print(F(" "));
  627.  
  628. promoFive = counter;
  629. EEPROM.put(eeAddressJ, promoFive);
  630. EEPROM.commit();
  631. }
  632. else if (counterChange == 11)
  633. {
  634. EEPROM.put(eeAddressA, promo1);
  635. EEPROM.put(eeAddressB, promoOne);
  636. EEPROM.put(eeAddressC, promo2);
  637. EEPROM.put(eeAddressD, promoTwo);
  638. EEPROM.put(eeAddressE, promo3);
  639. EEPROM.put(eeAddressF, promoThree);
  640. EEPROM.put(eeAddressG, promo4);
  641. EEPROM.put(eeAddressH, promoFour);
  642. EEPROM.put(eeAddressI, promo5);
  643. EEPROM.put(eeAddressJ, promoFive);
  644. EEPROM.put(eeAddressK, perPisoMin);
  645. EEPROM.commit();
  646.  
  647. lcd.setCursor(0, 0);
  648. lcd.print(F(" PROMO 1 TO 5 PRICE "));
  649. lcd.setCursor(0, 1);
  650. lcd.print(F("AND HOURS ARE SAVED!"));
  651. lcd.setCursor(0, 2);
  652. lcd.print(F("PLEASE WAIT........."));
  653. lcd.setCursor(0, 3);
  654. lcd.print(F(" "));
  655. counterChange = 0;
  656. delay(3000);
  657. resetVariable();
  658. editMode = false;
  659. displayMainMessage = true;
  660.  
  661. displayCheck();
  662. }
  663. }
  664. }
  665.  
  666. void noNegative() {
  667. if (counter < 0)
  668. {
  669. counter = 0;
  670. }
  671. }
  672.  
  673. void displayVoucher() {
  674. if (displayVouch)
  675. {
  676. M_command += "/ip hotspot user add name=";
  677. M_command += userCode;
  678. M_command += " limit-uptime=";
  679. M_command += promoFinal;
  680. int command_len = M_command.length() + 1;
  681. char M_F_command[command_len];
  682. M_command.toCharArray(M_F_command, command_len);
  683. tc.sendCommand(M_F_command);
  684. M_command = "";
  685. memset(M_F_command , 0, sizeof(M_F_command ));
  686. delay(100);
  687. Serial.begin(9600);
  688. printer.wake();
  689. coins = 0;
  690. lcd.setCursor(0, 0);
  691. lcd.print(F("Your voucher code is"));
  692. lcd.setCursor(0, 1);
  693. lcd.print(F(" <<"));
  694. lcd.print(userCode);
  695. lcd.print(F(">> "));
  696.  
  697. printer.justify('C');
  698. printer.println(F(""));
  699. printer.setSize('M');
  700. printer.println(F("Your voucher code is"));
  701. printer.setSize('L');
  702. printer.println(userCode);
  703. printer.println(F(""));
  704. printer.println(F(""));
  705. printer.println(F(""));
  706. delay(100);
  707.  
  708.  
  709.  
  710. //map320
  711. //
  712. // lcd.setCursor(0, 1);
  713. // lcd.print(promoFinal);
  714. format(promoFinal);
  715.  
  716. }
  717. }
  718.  
  719. void resetVariable() {
  720. printer.sleep();
  721. Serial.end();
  722. counterChange = 0;
  723. displayVouch = false;
  724. editMode = false;
  725. displayMainMessage = true;
  726. counter = 0;
  727. dummyCounter = 0;
  728. displayCoinCount = false;
  729. coins = 0;
  730. }
  731.  
  732. void displayCoin() {
  733. if (displayCoinCount)
  734. {
  735. lcd.setCursor(0, 0);
  736. lcd.print(F("Coins Inserted : "));
  737. lcd.setCursor(0, 1);
  738. lcd.print(coins);
  739. lcd.print(F(" "));
  740.  
  741. lcdCoin = coins;
  742. // lcd.setCursor(4, 0);
  743. // // checkPromo();
  744. //
  745. // lcd.print(promoFinal);
  746. temp = promoFinal;
  747.  
  748. format(promoFinal);
  749.  
  750. }
  751. }
  752.  
  753. void checkPromo() {
  754. // if (lcdCoin < promo1)
  755. // {
  756. // promoFinal = computation * lcdCoin;
  757. // }
  758. // else if (lcdCoin >= promo1 && lcdCoin < promo2)
  759. // {
  760. // promoTime = promoOne * promoHour;
  761. // promoComp = lcdCoin % promo1; //40 yung coin count, pumasok sa coin count na 30 tas may sampong piso na per rate na in between
  762. // inBetween = promoComp * computation; //REMAINDER MULTIPLY MO SA PRESYO PER PISO TAS ADD MO YUNG REMAINDER
  763. // promoFinal = inBetween + promoTime;
  764. // }
  765. // else if (lcdCoin >= promo2 && lcdCoin < promo3)
  766. // {
  767. // promoTime = promoTwo * promoHour;
  768. // promoComp = lcdCoin % promo2; //40 yung coin count, pumasok sa coin count na 30 tas may sampong piso na per rate na in between
  769. // inBetween = promoComp * computation; //REMAINDER MULTIPLY MO SA PRESYO PER PISO TAS ADD MO YUNG REMAINDER
  770. // promoFinal = inBetween + promoTime;
  771. //
  772. // }
  773. // else if (lcdCoin >= promo3 && lcdCoin < promo4)
  774. // {
  775. // promoComp = lcdCoin % promo3; //40 yung coin count, pumasok sa coin count na 30 tas may sampong piso na per rate na in between
  776. // inBetween = promoComp * computation; //REMAINDER MULTIPLY MO SA PRESYO PER PISO TAS ADD MO YUNG REMAINDER
  777. // promoTime = promoThree * promoHour;
  778. // promoFinal = inBetween + promoTime; //FINAL SHIT
  779. // }
  780. // else if (lcdCoin == promo4)
  781. // {
  782. // promoTime = promoFour * promoHour;
  783. // promoFinal = inBetween + promoTime;
  784. // }
  785. // else if (lcdCoin >= promo4 && lcdCoin < promo5)
  786. // {
  787. // promoComp = lcdCoin % promo4;
  788. // inBetween = promoComp * computation;
  789. // promoTime = promoFour * promoHour;
  790. // promoFinal = inBetween + promoTime;
  791. // }
  792. // else if (lcdCoin >= promo5)
  793. // {
  794. // promoComp = lcdCoin % promo5; //40 yung coin count, pumasok sa coin count na 30 tas may sampong piso na per rate na in between
  795. // inBetween = promoComp * computation; //REMAINDER MULTIPLY MO SA PRESYO PER PISO TAS ADD MO YUNG REMAINDER
  796. // promoTime = promoFive * promoHour;
  797. // promoFinal = inBetween + promoTime; //FINAL SHIT
  798. // }
  799. }
  800.  
  801. void format( long seconds) {
  802. long W = seconds / 604800;
  803. seconds = seconds % 604800;
  804. long D = seconds / 86400;
  805. seconds = seconds % 86400; //map999
  806. long H = seconds / 3600;
  807. seconds = seconds % 3600;
  808. long M = seconds / 60;
  809. long S = seconds % 60;
  810.  
  811. lcd.setCursor(0, 2);
  812. lcd.print(F("Voucher Duration : "));
  813. lcd.setCursor(0, 3);
  814. lcd.print(W);
  815. lcd.print(F("W"));
  816. lcd.print(F("-"));
  817. lcd.print(D);
  818. lcd.print(F("D"));
  819. lcd.print(F("-"));
  820. lcd.print(H);
  821. lcd.print(F("H"));
  822. lcd.print(F(":"));
  823. lcd.print(M);
  824. lcd.print(F("M"));
  825. lcd.print(F(" "));
  826. }
Add Comment
Please, Sign In to add comment