naivxnaivet

Test

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