naivxnaivet

TestingWithSave

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