From c43e7d379f5cb2807350fc45a84643b9f641a2c2 Mon Sep 17 00:00:00 2001 From: tuxmain Date: Thu, 8 Sep 2022 11:50:21 +0200 Subject: [PATCH] Capacitive buttons --- README.md | 10 +- alarmclock/alarmclock.kicad_sch | 688 ++++++++++---------------------- matrixclock/matrixclock.ino | 154 ++++--- 3 files changed, 286 insertions(+), 566 deletions(-) diff --git a/README.md b/README.md index 4c55abe..fcb8f56 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,14 @@ # Alarm clock -Arduino alarm clock with binary matrix LED display and IR remote control. +Arduino alarm clock with binary matrix LED display and capacitive touch buttons. ## Features * 8×8 LED display using two 74HC595N * hour-minute-second binary display * buzzer alarm -* IR remote control for settings and stopping alarm +* capacitive touch buttons for settings * big pushbutton for stopping alarm -* light sensor for dimming display -* better calibrate LED brightness ## Notes @@ -24,6 +22,10 @@ A NE555 is used for generating a high-frequency PWM signal, feeding one 74HC's " * date (at least weekday) * connection with online timetable? * progressive alarm ringing +* capacitive sensing causes LED matrix to flicker +* better calibrate display PWM +* light sensor for display PWM +* save alarm time & automatically retrieve time from network or RF ## License diff --git a/alarmclock/alarmclock.kicad_sch b/alarmclock/alarmclock.kicad_sch index e2b03f1..8cb3117 100644 --- a/alarmclock/alarmclock.kicad_sch +++ b/alarmclock/alarmclock.kicad_sch @@ -379,235 +379,6 @@ ) ) ) - (symbol "Interface_Optical:TSOP32S40F" (pin_names (offset 1.016)) (in_bom yes) (on_board yes) - (property "Reference" "U" (id 0) (at -10.16 7.62 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Value" "TSOP32S40F" (id 1) (at -10.16 -7.62 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Footprint" "OptoDevice:Vishay_MOLD-3Pin" (id 2) (at -1.27 -9.525 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "http://www.vishay.com/docs/82669/tsop32s40f.pdf" (id 3) (at 16.51 7.62 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_keywords" "opto IR receiver" (id 4) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_description" "IR Receiver Modules for Remote Control Systems" (id 5) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_fp_filters" "Vishay*MOLD*" (id 6) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (symbol "TSOP32S40F_0_0" - (arc (start -10.287 1.397) (mid -11.0899 -0.1852) (end -10.287 -1.778) - (stroke (width 0.254) (type default) (color 0 0 0 0)) - (fill (type background)) - ) - (polyline - (pts - (xy 1.905 -5.08) - (xy 0.127 -5.08) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.905 5.08) - (xy 0.127 5.08) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (text "DEMOD" (at -3.175 0.254 900) - (effects (font (size 1.524 1.524))) - ) - ) - (symbol "TSOP32S40F_0_1" - (rectangle (start -6.096 5.588) (end 0.127 -5.588) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -8.763 0.381) - (xy -9.652 1.27) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -8.763 0.381) - (xy -9.271 0.381) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -8.763 0.381) - (xy -8.763 0.889) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -8.636 -0.635) - (xy -9.525 0.254) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -8.636 -0.635) - (xy -9.144 -0.635) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -8.636 -0.635) - (xy -8.636 -0.127) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -8.382 -1.016) - (xy -6.731 -1.016) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.27 -2.921) - (xy 0.127 -2.921) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.27 -1.905) - (xy 1.27 -3.81) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.397 -3.556) - (xy 1.524 -3.556) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.651 -3.556) - (xy 1.524 -3.556) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.651 -3.556) - (xy 1.651 -3.302) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.905 0) - (xy 1.905 1.27) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.905 4.445) - (xy 1.905 5.08) - (xy 2.54 5.08) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -8.382 0.635) - (xy -6.731 0.635) - (xy -7.62 -1.016) - (xy -8.382 0.635) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type outline)) - ) - (polyline - (pts - (xy -6.096 1.397) - (xy -7.62 1.397) - (xy -7.62 -1.778) - (xy -6.096 -1.778) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.27 -3.175) - (xy 1.905 -3.81) - (xy 1.905 -5.08) - (xy 2.54 -5.08) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy 1.27 -2.54) - (xy 1.905 -1.905) - (xy 1.905 0) - (xy 2.54 0) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (rectangle (start 2.54 1.27) (end 1.27 4.445) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (rectangle (start 7.62 6.35) (end -10.16 -6.35) - (stroke (width 0.254) (type default) (color 0 0 0 0)) - (fill (type background)) - ) - ) - (symbol "TSOP32S40F_1_1" - (pin output line (at 10.16 0 180) (length 2.54) - (name "OUT" (effects (font (size 1.27 1.27)))) - (number "1" (effects (font (size 1.27 1.27)))) - ) - (pin power_in line (at 10.16 5.08 180) (length 2.54) - (name "Vs" (effects (font (size 1.27 1.27)))) - (number "2" (effects (font (size 1.27 1.27)))) - ) - (pin power_in line (at 10.16 -5.08 180) (length 2.54) - (name "GND" (effects (font (size 1.27 1.27)))) - (number "3" (effects (font (size 1.27 1.27)))) - ) - ) - ) (symbol "MCU_Module:Arduino_UNO_R3" (in_bom yes) (on_board yes) (property "Reference" "A" (id 0) (at -10.16 23.495 0) (effects (font (size 1.27 1.27)) (justify left bottom)) @@ -767,93 +538,6 @@ ) ) ) - (symbol "Sensor_Optical:LDR07" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes) - (property "Reference" "R" (id 0) (at -5.08 0 90) - (effects (font (size 1.27 1.27))) - ) - (property "Value" "LDR07" (id 1) (at 1.905 0 90) - (effects (font (size 1.27 1.27)) (justify top)) - ) - (property "Footprint" "OptoDevice:R_LDR_5.1x4.3mm_P3.4mm_Vertical" (id 2) (at 4.445 0 90) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "http://www.tme.eu/de/Document/f2e3ad76a925811312d226c31da4cd7e/LDR07.pdf" (id 3) (at 0 -1.27 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_keywords" "light dependent photo resistor LDR" (id 4) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_description" "light dependent resistor" (id 5) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "ki_fp_filters" "R*LDR*5.1x4.3mm*P3.4mm*" (id 6) (at 0 0 0) - (effects (font (size 1.27 1.27)) hide) - ) - (symbol "LDR07_0_1" - (rectangle (start -1.016 2.54) (end 1.016 -2.54) - (stroke (width 0.254) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -1.524 -2.286) - (xy -4.064 0.254) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -1.524 -2.286) - (xy -2.286 -2.286) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -1.524 -2.286) - (xy -1.524 -1.524) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -1.524 -0.762) - (xy -4.064 1.778) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -1.524 -0.762) - (xy -2.286 -0.762) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - (polyline - (pts - (xy -1.524 -0.762) - (xy -1.524 0) - ) - (stroke (width 0) (type default) (color 0 0 0 0)) - (fill (type none)) - ) - ) - (symbol "LDR07_1_1" - (pin passive line (at 0 3.81 270) (length 1.27) - (name "~" (effects (font (size 1.27 1.27)))) - (number "1" (effects (font (size 1.27 1.27)))) - ) - (pin passive line (at 0 -3.81 90) (length 1.27) - (name "~" (effects (font (size 1.27 1.27)))) - (number "2" (effects (font (size 1.27 1.27)))) - ) - ) - ) (symbol "Switch:SW_Push" (pin_numbers hide) (pin_names (offset 1.016) hide) (in_bom yes) (on_board yes) (property "Reference" "SW" (id 0) (at 1.27 2.54 0) (effects (font (size 1.27 1.27)) (justify left)) @@ -1129,9 +813,18 @@ (junction (at 107.95 96.52) (diameter 0) (color 0 0 0 0) (uuid 1be33e30-ecc6-43ae-8f26-d45550e4edeb) ) + (junction (at 132.08 151.13) (diameter 0) (color 0 0 0 0) + (uuid 27f8c622-996b-499e-96da-a600683076c7) + ) + (junction (at 158.75 135.89) (diameter 0) (color 0 0 0 0) + (uuid 438d8f18-2c30-43d8-bfe5-8140cf3f3b45) + ) (junction (at 93.98 90.17) (diameter 0) (color 0 0 0 0) (uuid 4ae13326-4ca7-415c-bcc2-1eac3539207a) ) + (junction (at 158.75 140.97) (diameter 0) (color 0 0 0 0) + (uuid 57a7ae9f-2c85-4d8e-9dd8-bb21ef5bbcdc) + ) (junction (at 81.28 189.23) (diameter 0) (color 0 0 0 0) (uuid 657da6b5-99bf-45e6-a025-a1a955090760) ) @@ -1144,18 +837,27 @@ (junction (at 81.28 96.52) (diameter 0) (color 0 0 0 0) (uuid 82f9ca19-7f27-4546-8597-40a4871f604f) ) + (junction (at 137.16 140.97) (diameter 0) (color 0 0 0 0) + (uuid 8f0fd405-8e61-436b-b29b-6db3273750d5) + ) + (junction (at 158.75 146.05) (diameter 0) (color 0 0 0 0) + (uuid 978f5b26-567a-42f3-9a85-001ac295434c) + ) (junction (at 91.44 189.23) (diameter 0) (color 0 0 0 0) (uuid a1a23778-2c11-413b-8356-4012bd9da2b9) ) + (junction (at 139.7 135.89) (diameter 0) (color 0 0 0 0) + (uuid a491fcc3-3113-47e1-b9cf-b888249f19a9) + ) (junction (at 110.49 99.06) (diameter 0) (color 0 0 0 0) (uuid ae022e79-4672-4103-afe8-459a29f9949e) ) + (junction (at 134.62 146.05) (diameter 0) (color 0 0 0 0) + (uuid b54244cf-e976-4e0e-aab1-e100795fe8de) + ) (junction (at 81.28 181.61) (diameter 0) (color 0 0 0 0) (uuid b6ec9ae1-01a6-40af-9342-606b48aa2be7) ) - (junction (at 176.53 96.52) (diameter 0) (color 0 0 0 0) - (uuid d532b373-8bef-483d-94ce-38f5ccfb39d7) - ) (junction (at 68.58 181.61) (diameter 0) (color 0 0 0 0) (uuid e5c9879b-8f0d-4695-86b5-5d6a528afdbf) ) @@ -1166,14 +868,22 @@ (uuid fc0f8902-fef2-4b55-9370-d2436cfb42df) ) - (wire (pts (xy 139.7 140.97) (xy 139.7 106.68)) - (stroke (width 0) (type default) (color 0 0 0 0)) - (uuid 01720954-ebd0-4fe4-8ab9-e09bb6c4a6fd) - ) (wire (pts (xy 91.44 147.32) (xy 87.63 147.32)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 029ee0a7-dc7c-491d-86b2-4e47ebf56ce3) ) + (wire (pts (xy 142.24 104.14) (xy 132.08 104.14)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 032636ae-ccfa-4b18-bc6c-55c9c8898355) + ) + (wire (pts (xy 170.18 99.06) (xy 170.18 135.89)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 0347be9d-bb81-42de-8687-7d78c9d78931) + ) + (wire (pts (xy 137.16 106.68) (xy 137.16 140.97)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 076b68ab-f45c-4aa6-8303-9d1666e43d79) + ) (wire (pts (xy 68.58 147.32) (xy 77.47 147.32)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 07d8fb4c-d77c-4bc9-902c-7d2b0d092433) @@ -1202,10 +912,26 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 173ad493-5ce5-4a7c-9e85-c849dbfd0749) ) + (wire (pts (xy 158.75 140.97) (xy 158.75 146.05)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 1decbc96-4d09-470d-90b5-8007e552c881) + ) + (wire (pts (xy 139.7 109.22) (xy 139.7 135.89)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 20e1e8ee-99ab-4e44-8fc5-a42f193f3f37) + ) + (wire (pts (xy 142.24 109.22) (xy 139.7 109.22)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 218d52c3-fb66-48f4-bc6e-99f453fcbd4e) + ) (wire (pts (xy 91.44 109.22) (xy 95.25 109.22)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 27deaa24-d5e1-46f4-93d6-9b974e798f3f) ) + (wire (pts (xy 167.64 99.06) (xy 170.18 99.06)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 2870214c-3d1d-4d44-ab4d-60954b70b321) + ) (wire (pts (xy 91.44 165.1) (xy 91.44 179.07)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 29e22f7d-a810-4575-8a7d-3d3562727bf0) @@ -1226,10 +952,6 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 315b9383-0d5e-4ae6-9344-bfeece476e6b) ) - (wire (pts (xy 135.89 134.62) (xy 135.89 135.89)) - (stroke (width 0) (type default) (color 0 0 0 0)) - (uuid 32efbf43-074b-4b68-8ba0-078b16b86f82) - ) (wire (pts (xy 93.98 77.47) (xy 93.98 90.17)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 386f5dfe-1117-4feb-9d4e-7473c6e7231c) @@ -1238,7 +960,7 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 3c1e82c9-fea0-48a6-845c-322736992719) ) - (wire (pts (xy 139.7 106.68) (xy 142.24 106.68)) + (wire (pts (xy 137.16 106.68) (xy 142.24 106.68)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 3d19638c-f994-4afd-9452-69496fc15ed5) ) @@ -1246,6 +968,10 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 4f96485b-79c9-4e23-ad0f-282e3d835b81) ) + (wire (pts (xy 129.54 140.97) (xy 137.16 140.97)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 50ef5b1c-63cf-4a32-90ed-f3c1f3a12c7e) + ) (wire (pts (xy 78.74 181.61) (xy 81.28 181.61)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 57ffaaf0-e14e-442c-8cce-905d6abfe55e) @@ -1258,6 +984,10 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 5db1cc82-cede-4a46-a004-1347419de76f) ) + (wire (pts (xy 137.16 140.97) (xy 151.13 140.97)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 5ec3842a-4522-4b00-b3e2-1d685d61625c) + ) (wire (pts (xy 105.41 93.98) (xy 142.24 93.98)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 5ed8222e-e54b-48f9-8b21-6489d05a2cae) @@ -1266,10 +996,30 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 5f722d5d-d544-49c2-9089-731af724b30c) ) + (wire (pts (xy 129.54 146.05) (xy 134.62 146.05)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 605c6875-e071-43d8-9ed0-7c5280279205) + ) + (wire (pts (xy 129.54 151.13) (xy 132.08 151.13)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 6209fb16-d7e6-4b08-98c5-948f859c1d9d) + ) + (wire (pts (xy 158.75 135.89) (xy 158.75 140.97)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 659e8434-625e-47c1-8cba-bab9b91ed40f) + ) (wire (pts (xy 100.33 171.45) (xy 100.33 165.1)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 6982f50f-4bd6-4e65-aa54-48b3a88f87c8) ) + (wire (pts (xy 139.7 135.89) (xy 151.13 135.89)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 6cb4d0ae-55cd-46cf-a127-5572de60ef79) + ) + (wire (pts (xy 132.08 151.13) (xy 151.13 151.13)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 6e19165f-08e4-49c2-92cf-6c6da113086e) + ) (wire (pts (xy 91.44 77.47) (xy 93.98 77.47)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 6e36634f-cae9-4d73-afb1-0a3b14b7f072) @@ -1278,18 +1028,22 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 73183147-78a4-4aac-b280-a1d8040f2556) ) - (wire (pts (xy 167.64 96.52) (xy 176.53 96.52)) - (stroke (width 0) (type default) (color 0 0 0 0)) - (uuid 74011baf-c7fb-49dc-8af7-81ca1e95cf58) - ) (wire (pts (xy 110.49 106.68) (xy 110.49 99.06)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 75f9e204-ce7d-4b50-8827-c5d1cfbe834c) ) + (wire (pts (xy 134.62 146.05) (xy 151.13 146.05)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 783546c3-1c40-4099-9f00-4805aacd3ade) + ) (wire (pts (xy 49.53 165.1) (xy 49.53 189.23)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 7b0fd84d-affd-46e5-b49a-3ce0a28ec97b) ) + (wire (pts (xy 142.24 86.36) (xy 134.62 86.36)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 7fa7ca00-0b0d-44cc-a7a6-1021a1fc7f67) + ) (wire (pts (xy 107.95 114.3) (xy 107.95 96.52)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 8344dbc9-9b1f-416c-bcbd-dec81bfc7d3a) @@ -1298,6 +1052,10 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 86bb9bd6-0fa4-4bae-ab0d-0775f0d2bec8) ) + (wire (pts (xy 134.62 86.36) (xy 134.62 146.05)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 8e91a7e7-13b5-4cf3-b517-3a2c4bc653a3) + ) (wire (pts (xy 95.25 96.52) (xy 81.28 96.52)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 92ef4347-551d-4e63-ba76-1bc041c8c835) @@ -1322,11 +1080,7 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid 9cec63d3-be77-4e80-9129-8d30d3f0b5a5) ) - (wire (pts (xy 135.89 140.97) (xy 139.7 140.97)) - (stroke (width 0) (type default) (color 0 0 0 0)) - (uuid 9da2ba3f-5ff0-4eb1-a1e7-abe97b23bd52) - ) - (wire (pts (xy 134.62 88.9) (xy 142.24 88.9)) + (wire (pts (xy 127 88.9) (xy 142.24 88.9)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid a342cc1e-8d2b-4088-9007-a7f22abf5a85) ) @@ -1362,10 +1116,18 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid b6a3930e-d171-4bfa-bacf-e8326b33f217) ) + (wire (pts (xy 170.18 135.89) (xy 158.75 135.89)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid b78e06d3-1b4a-4c9d-8f7c-027598c30ed1) + ) (wire (pts (xy 91.44 189.23) (xy 100.33 189.23)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid b8578491-bd7f-4173-9ec3-27808b7eb94a) ) + (wire (pts (xy 129.54 135.89) (xy 139.7 135.89)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid bf2a4884-c2ac-401c-86c4-1b1504257144) + ) (wire (pts (xy 49.53 189.23) (xy 81.28 189.23)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid c17e5ec6-eea8-407b-8b1f-e0c06299135d) @@ -1382,6 +1144,14 @@ (stroke (width 0) (type default) (color 0 0 0 0)) (uuid ce21daba-68c6-4c5a-92a3-ce60fbe83bfa) ) + (wire (pts (xy 158.75 146.05) (xy 158.75 151.13)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid d69a0727-aaf4-4134-9f88-d2d21a0dbda8) + ) + (wire (pts (xy 132.08 104.14) (xy 132.08 151.13)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid dc0b9768-0d19-4980-8dd0-4ef2b034f923) + ) (wire (pts (xy 82.55 170.18) (xy 82.55 163.83)) (stroke (width 0) (type default) (color 0 0 0 0)) (uuid dd36533d-5b06-4da6-8fbe-9f106f2c10f4) @@ -1432,6 +1202,35 @@ (uuid 276e5dba-9dc6-4be8-a1af-c107b7040c6a) ) + (global_label "Touch" (shape input) (at 129.54 146.05 180) (fields_autoplaced) + (effects (font (size 1.27 1.27)) (justify right)) + (uuid 00c9f3c7-1762-41e7-ae63-52661a08efda) + (property "Références Inter-Feuilles" "${INTERSHEET_REFS}" (id 0) (at 121.6236 145.9706 0) + (effects (font (size 1.27 1.27)) (justify right) hide) + ) + ) + (global_label "Touch" (shape input) (at 129.54 140.97 180) (fields_autoplaced) + (effects (font (size 1.27 1.27)) (justify right)) + (uuid 231a2936-b2f3-4c9b-baa9-7b7ae7743423) + (property "Références Inter-Feuilles" "${INTERSHEET_REFS}" (id 0) (at 121.6236 140.8906 0) + (effects (font (size 1.27 1.27)) (justify right) hide) + ) + ) + (global_label "Touch" (shape input) (at 129.54 151.13 180) (fields_autoplaced) + (effects (font (size 1.27 1.27)) (justify right)) + (uuid 3a6a8b86-760c-45eb-ace7-3dcb89310870) + (property "Références Inter-Feuilles" "${INTERSHEET_REFS}" (id 0) (at 121.6236 151.0506 0) + (effects (font (size 1.27 1.27)) (justify right) hide) + ) + ) + (global_label "Touch" (shape input) (at 129.54 135.89 180) (fields_autoplaced) + (effects (font (size 1.27 1.27)) (justify right)) + (uuid 7ee052db-a995-4535-a6ec-1faef737b2b4) + (property "Références Inter-Feuilles" "${INTERSHEET_REFS}" (id 0) (at 121.6236 135.8106 0) + (effects (font (size 1.27 1.27)) (justify right) hide) + ) + ) + (symbol (lib_id "Device:R") (at 113.03 124.46 270) (unit 1) (in_bom yes) (on_board yes) (fields_autoplaced) (uuid 0d696145-2ec2-4bef-994b-9f1c8758cd4d) @@ -1463,6 +1262,36 @@ (pin "1" (uuid 21da5f7d-a0c0-4984-8491-169d486f9457)) ) + (symbol (lib_id "Device:R") (at 154.94 146.05 90) (unit 1) + (in_bom yes) (on_board yes) + (uuid 10cff9ee-765c-4e87-8878-2577e6db0b89) + (property "Reference" "R10" (id 0) (at 154.94 146.05 90)) + (property "Value" "470kΩ" (id 1) (at 154.94 143.51 90)) + (property "Footprint" "" (id 2) (at 154.94 147.828 90) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 154.94 146.05 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid dd02cb6e-78c2-4606-87b5-76ea43dca663)) + (pin "2" (uuid f15d0ec3-af8a-4daa-ae27-a10eb46f1d82)) + ) + + (symbol (lib_id "Device:R") (at 154.94 140.97 90) (unit 1) + (in_bom yes) (on_board yes) + (uuid 12c97f0d-5819-4817-8ffd-4a769c416236) + (property "Reference" "R9" (id 0) (at 154.94 140.97 90)) + (property "Value" "2MΩ" (id 1) (at 154.94 138.43 90)) + (property "Footprint" "" (id 2) (at 154.94 142.748 90) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 154.94 140.97 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid dfcb26c9-00e2-4ee9-bd12-7fc09b691a19)) + (pin "2" (uuid 8a2e7c88-f5f8-40c4-82eb-da110ca70777)) + ) + (symbol (lib_id "power:+5V") (at 160.02 71.12 0) (unit 1) (in_bom yes) (on_board yes) (fields_autoplaced) (uuid 141a79ea-d231-4dbf-9c06-a05c2ffa3c1d) @@ -1479,25 +1308,6 @@ (pin "1" (uuid eb243f0b-1352-421f-bec7-8db4af5d0c2e)) ) - (symbol (lib_id "Device:R") (at 176.53 100.33 180) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid 1eb8f36d-7d0c-4e5e-9fe2-5070db5fd7e3) - (property "Reference" "R3" (id 0) (at 179.07 99.0599 0) - (effects (font (size 1.27 1.27)) (justify right)) - ) - (property "Value" "10kΩ" (id 1) (at 179.07 101.5999 0) - (effects (font (size 1.27 1.27)) (justify right)) - ) - (property "Footprint" "" (id 2) (at 178.308 100.33 90) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "~" (id 3) (at 176.53 100.33 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 134c348d-6d65-4204-867a-3f776c82577d)) - (pin "2" (uuid cd9f54d7-ecb6-4f6b-8393-8d47655c7dfa)) - ) - (symbol (lib_id "Device:Buzzer") (at 106.68 127 0) (mirror y) (unit 1) (in_bom yes) (on_board yes) (fields_autoplaced) (uuid 20e06040-d647-4f00-8cdf-985064ab739e) @@ -1513,38 +1323,6 @@ (pin "2" (uuid bd650711-e39e-428e-8a6a-2863be2014e8)) ) - (symbol (lib_id "power:GND") (at 176.53 104.14 0) (unit 1) - (in_bom yes) (on_board yes) - (uuid 2149f34b-2a09-42c6-a1a7-99baf49f5b8e) - (property "Reference" "#PWR?" (id 0) (at 176.53 110.49 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Value" "GND" (id 1) (at 176.53 107.95 0)) - (property "Footprint" "" (id 2) (at 176.53 104.14 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "" (id 3) (at 176.53 104.14 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 6640eb2c-8d96-470c-94cd-56909fc8350b)) - ) - - (symbol (lib_id "power:+5V") (at 135.89 134.62 0) (unit 1) - (in_bom yes) (on_board yes) - (uuid 301a8c1c-845a-4d25-a06f-7c09bae9ce79) - (property "Reference" "#PWR?" (id 0) (at 135.89 138.43 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Value" "+5V" (id 1) (at 135.89 130.81 0)) - (property "Footprint" "" (id 2) (at 135.89 134.62 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "" (id 3) (at 135.89 134.62 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 302551ac-c512-4dc5-be35-d3c29f4f30c6)) - ) - (symbol (lib_id "Device:R") (at 82.55 160.02 180) (unit 1) (in_bom yes) (on_board yes) (fields_autoplaced) (uuid 44629472-077b-4fd8-ab99-7bd1e7b23c99) @@ -1632,38 +1410,6 @@ (pin "2" (uuid 5e35d793-1f80-4ca3-aac2-bf2d25469e2c)) ) - (symbol (lib_id "power:GND") (at 135.89 146.05 0) (unit 1) - (in_bom yes) (on_board yes) - (uuid 7aefc256-28c5-4fca-b228-7eb3f739e209) - (property "Reference" "#PWR?" (id 0) (at 135.89 152.4 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Value" "GND" (id 1) (at 135.89 149.86 0)) - (property "Footprint" "" (id 2) (at 135.89 146.05 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "" (id 3) (at 135.89 146.05 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 5386b8f9-cf77-4761-8b81-8251c98a3873)) - ) - - (symbol (lib_id "Interface_Optical:TSOP32S40F") (at 125.73 140.97 0) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid 7b556d3a-1886-4d11-a4ea-75d7ccf91a58) - (property "Reference" "U3" (id 0) (at 123.995 129.54 0)) - (property "Value" "TSOP32S40F" (id 1) (at 123.995 132.08 0)) - (property "Footprint" "OptoDevice:Vishay_MOLD-3Pin" (id 2) (at 124.46 150.495 0) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "http://www.vishay.com/docs/82669/tsop32s40f.pdf" (id 3) (at 142.24 133.35 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 4d0d5217-0ead-43ac-8f00-85bfc10124cd)) - (pin "2" (uuid 12a094c6-25b8-4545-bc73-e4594285558d)) - (pin "3" (uuid 8dc663e1-02ab-43a5-99f1-08b76b4da361)) - ) - (symbol (lib_id "pspice:DIODE") (at 100.33 184.15 270) (unit 1) (in_bom yes) (on_board yes) (uuid 8383015f-a57d-4f92-9d19-230a2159f139) @@ -1702,20 +1448,34 @@ (pin "2" (uuid 1a472c3e-2f4f-4d83-b001-81cae425cfa3)) ) - (symbol (lib_id "power:+5V") (at 176.53 88.9 0) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid 9c41a0ab-d2cc-47f8-b12b-9acb54862052) - (property "Reference" "#PWR?" (id 0) (at 176.53 92.71 0) + (symbol (lib_id "Device:R") (at 154.94 135.89 90) (unit 1) + (in_bom yes) (on_board yes) + (uuid a6b2f61b-8aca-46c6-bf28-31f7f16e09c5) + (property "Reference" "R8" (id 0) (at 154.94 135.89 90)) + (property "Value" "2MΩ" (id 1) (at 154.94 133.35 90)) + (property "Footprint" "" (id 2) (at 154.94 137.668 90) (effects (font (size 1.27 1.27)) hide) ) - (property "Value" "+5V" (id 1) (at 176.53 83.82 0)) - (property "Footprint" "" (id 2) (at 176.53 88.9 0) + (property "Datasheet" "~" (id 3) (at 154.94 135.89 0) (effects (font (size 1.27 1.27)) hide) ) - (property "Datasheet" "" (id 3) (at 176.53 88.9 0) + (pin "1" (uuid b6df39a2-9ac0-4000-93a0-4e626b4346df)) + (pin "2" (uuid ce00982c-f6ce-430d-9515-c41a4c878145)) + ) + + (symbol (lib_id "Device:R") (at 154.94 151.13 90) (unit 1) + (in_bom yes) (on_board yes) + (uuid a6c5f130-4baa-4458-b339-a18efbae243f) + (property "Reference" "R11" (id 0) (at 154.94 151.13 90)) + (property "Value" "470kΩ" (id 1) (at 154.94 148.59 90)) + (property "Footprint" "" (id 2) (at 154.94 152.908 90) (effects (font (size 1.27 1.27)) hide) ) - (pin "1" (uuid 856457e8-069c-4e02-92b4-fc0e82a35eb5)) + (property "Datasheet" "~" (id 3) (at 154.94 151.13 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid f0d4de58-eee3-4e0b-9d28-ded3fd5aba66)) + (pin "2" (uuid 1e2d1df1-e261-4c17-bddf-23ff67b21463)) ) (symbol (lib_id "power:GND") (at 81.28 129.54 0) (unit 1) @@ -1734,17 +1494,17 @@ (pin "1" (uuid 39d0e4ed-44c8-46a8-bf5f-021e67df9cab)) ) - (symbol (lib_id "power:GND") (at 124.46 88.9 0) (unit 1) + (symbol (lib_id "power:GND") (at 116.84 88.9 0) (unit 1) (in_bom yes) (on_board yes) (uuid b026f555-902c-4e06-8246-0ad63d17f407) - (property "Reference" "#PWR?" (id 0) (at 124.46 95.25 0) + (property "Reference" "#PWR?" (id 0) (at 116.84 95.25 0) (effects (font (size 1.27 1.27)) hide) ) - (property "Value" "GND" (id 1) (at 124.46 92.71 0)) - (property "Footprint" "" (id 2) (at 124.46 88.9 0) + (property "Value" "GND" (id 1) (at 116.84 92.71 0)) + (property "Footprint" "" (id 2) (at 116.84 88.9 0) (effects (font (size 1.27 1.27)) hide) ) - (property "Datasheet" "" (id 3) (at 124.46 88.9 0) + (property "Datasheet" "" (id 3) (at 116.84 88.9 0) (effects (font (size 1.27 1.27)) hide) ) (pin "1" (uuid 6418e6d5-1d70-4e24-81f6-39d07f4edb38)) @@ -1855,17 +1615,17 @@ (pin "2" (uuid ca590cff-f51d-480e-9955-33d912733657)) ) - (symbol (lib_id "Switch:SW_Push") (at 129.54 88.9 0) (unit 1) + (symbol (lib_id "Switch:SW_Push") (at 121.92 88.9 0) (unit 1) (in_bom yes) (on_board yes) (uuid c473d886-4ff1-480b-b845-981b3467af5b) - (property "Reference" "SW1" (id 0) (at 129.54 83.82 0)) - (property "Value" "SW_Push" (id 1) (at 129.54 83.82 0) + (property "Reference" "SW1" (id 0) (at 121.92 83.82 0)) + (property "Value" "SW_Push" (id 1) (at 121.92 83.82 0) (effects (font (size 1.27 1.27)) hide) ) - (property "Footprint" "" (id 2) (at 129.54 83.82 0) + (property "Footprint" "" (id 2) (at 121.92 83.82 0) (effects (font (size 1.27 1.27)) hide) ) - (property "Datasheet" "~" (id 3) (at 129.54 83.82 0) + (property "Datasheet" "~" (id 3) (at 121.92 83.82 0) (effects (font (size 1.27 1.27)) hide) ) (pin "1" (uuid f8c13bd8-ceee-4cbd-be1d-e75862a9af00)) @@ -1985,25 +1745,6 @@ (pin "9" (uuid 2939070a-243b-4f6f-8953-8a568eacee32)) ) - (symbol (lib_id "Sensor_Optical:LDR07") (at 176.53 92.71 0) (unit 1) - (in_bom yes) (on_board yes) (fields_autoplaced) - (uuid f20a0d6f-d377-45a4-b121-f79bd50b9e38) - (property "Reference" "R2" (id 0) (at 179.07 91.4399 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Value" "LDR07" (id 1) (at 179.07 93.9799 0) - (effects (font (size 1.27 1.27)) (justify left)) - ) - (property "Footprint" "OptoDevice:R_LDR_5.1x4.3mm_P3.4mm_Vertical" (id 2) (at 180.975 92.71 90) - (effects (font (size 1.27 1.27)) hide) - ) - (property "Datasheet" "http://www.tme.eu/de/Document/f2e3ad76a925811312d226c31da4cd7e/LDR07.pdf" (id 3) (at 176.53 93.98 0) - (effects (font (size 1.27 1.27)) hide) - ) - (pin "1" (uuid 17082467-f25e-4a5b-82ec-ffb20cb6c3d7)) - (pin "2" (uuid 7aecafab-919c-4b9e-803e-f5b0636420a2)) - ) - (symbol (lib_id "power:+5V") (at 81.28 96.52 0) (unit 1) (in_bom yes) (on_board yes) (uuid f615f992-b304-49f7-b744-952f42fc0886) @@ -2063,18 +1804,6 @@ (path "/141a79ea-d231-4dbf-9c06-a05c2ffa3c1d" (reference "#PWR?") (unit 1) (value "+5V") (footprint "") ) - (path "/2149f34b-2a09-42c6-a1a7-99baf49f5b8e" - (reference "#PWR?") (unit 1) (value "GND") (footprint "") - ) - (path "/301a8c1c-845a-4d25-a06f-7c09bae9ce79" - (reference "#PWR?") (unit 1) (value "+5V") (footprint "") - ) - (path "/7aefc256-28c5-4fca-b228-7eb3f739e209" - (reference "#PWR?") (unit 1) (value "GND") (footprint "") - ) - (path "/9c41a0ab-d2cc-47f8-b12b-9acb54862052" - (reference "#PWR?") (unit 1) (value "+5V") (footprint "") - ) (path "/a7ce1889-2073-4b99-8cf9-d7d05599b709" (reference "#PWR?") (unit 1) (value "GND") (footprint "") ) @@ -2123,12 +1852,6 @@ (path "/0d696145-2ec2-4bef-994b-9f1c8758cd4d" (reference "R1") (unit 1) (value "161Ω") (footprint "") ) - (path "/f20a0d6f-d377-45a4-b121-f79bd50b9e38" - (reference "R2") (unit 1) (value "LDR07") (footprint "OptoDevice:R_LDR_5.1x4.3mm_P3.4mm_Vertical") - ) - (path "/1eb8f36d-7d0c-4e5e-9fe2-5070db5fd7e3" - (reference "R3") (unit 1) (value "10kΩ") (footprint "") - ) (path "/44629472-077b-4fd8-ab99-7bd1e7b23c99" (reference "R4") (unit 1) (value "1kΩ") (footprint "") ) @@ -2141,6 +1864,18 @@ (path "/9977633a-49d9-4dbb-8999-f08145d1842e" (reference "R7") (unit 1) (value "1MΩ") (footprint "") ) + (path "/a6b2f61b-8aca-46c6-bf28-31f7f16e09c5" + (reference "R8") (unit 1) (value "2MΩ") (footprint "") + ) + (path "/12c97f0d-5819-4817-8ffd-4a769c416236" + (reference "R9") (unit 1) (value "2MΩ") (footprint "") + ) + (path "/10cff9ee-765c-4e87-8878-2577e6db0b89" + (reference "R10") (unit 1) (value "470kΩ") (footprint "") + ) + (path "/a6c5f130-4baa-4458-b339-a18efbae243f" + (reference "R11") (unit 1) (value "470kΩ") (footprint "") + ) (path "/c473d886-4ff1-480b-b845-981b3467af5b" (reference "SW1") (unit 1) (value "SW_Push") (footprint "") ) @@ -2150,9 +1885,6 @@ (path "/b25f44e0-8181-464f-9dc7-fd49f1f26994" (reference "U2") (unit 1) (value "74HC595") (footprint "") ) - (path "/7b556d3a-1886-4d11-a4ea-75d7ccf91a58" - (reference "U3") (unit 1) (value "TSOP32S40F") (footprint "OptoDevice:Vishay_MOLD-3Pin") - ) (path "/bf2fa98c-2435-4029-ae7c-6ff5c5e45569" (reference "U4") (unit 1) (value "NE555P") (footprint "Package_DIP:DIP-8_W7.62mm") ) diff --git a/matrixclock/matrixclock.ino b/matrixclock/matrixclock.ino index e182926..66f1992 100644 --- a/matrixclock/matrixclock.ino +++ b/matrixclock/matrixclock.ino @@ -1,53 +1,23 @@ -#include +#include #define SERIAL_DEBUG 0 -// Remote controls -#define RC6_CHM 0xFFA25D// CHANNEL - -#define RC6_CH 0xFF629D// CHANNEL -#define RC6_CHP 0xFFE21D// CHANNEL + -#define RC6_PREV 0xFF22DD// |<< PREVIOUS -#define RC6_NEXT 0xFF02FD// >>| NEXT -#define RC6_PLAY 0xFFC23D// PLAY/PAUSE -#define RC6_VM 0xFFE01F// VOLUME - -#define RC6_VP 0xFFA857// VOLUME + -#define RC6_EQ 0xFF906F// EQ -#define RC6_0 0xFF6897// 0 -#define RC6_100 0xFF9867// 100+ -#define RC6_200 0xFFB04F// 200+ -#define RC6_1 0xFF30CF// 1 -#define RC6_2 0xFF18E7// 2 -#define RC6_3 0xFF7A85// 3 -#define RC6_4 0xFF10EF// 4 -#define RC6_5 0xFF38C7// 5 -#define RC6_6 0xFF5AA5// 6 -#define RC6_7 0xFF42BD// 7 -#define RC6_8 0xFF4AB5// 8 -#define RC6_9 0xFF52AD// 9 -#define AMP2540_VCDAUX 0x8FDBCE66 -#define AMP2540_TUNERCD 0xC375A98B -#define AMP2540_DVD 0xCC7372A6 -#define AMP2540_TAPE 0xE917A076 -#define AMP2540_SEARCH 0xE82D76B6 -#define AMP2540_RESET 0x04D1A486 -#define AMP2540_VM 0xAB95D276 -#define AMP2540_VP 0x0217C346 - #define MODE_NORMAL 0 #define MODE_SETTIME 1 #define MODE_SETALARM 2 #define PIN_BUTTON 3 -#define PIN_BUZZER 8 -#define PIN_IR 10 +#define PIN_BUZZER_LOUD 8 +#define PIN_BUZZER_QUIET 12 #define PIN_LED_DUTY A0 #define PIN_REG_CLOCK 7 #define PIN_REG_DATA 5 #define PIN_REG_LATCH 6 -IRrecv irrecv(PIN_IR); -decode_results ircode; -unsigned long last_ir = 0; +CapacitiveSensor touch_0 = CapacitiveSensor(A1, 11); +CapacitiveSensor touch_1 = CapacitiveSensor(A1, 10); +CapacitiveSensor touch_2 = CapacitiveSensor(A1, 2); +CapacitiveSensor touch_3 = CapacitiveSensor(A1, 9); // Matrix state unsigned char matrix[8] = {0b10000001, 0, 0, 0, 0, 0, 0, 0b10000001}; @@ -68,9 +38,12 @@ unsigned long alarm_time = 0; // Is alarm ringing unsigned char alarm_ringing = false; +unsigned long alarm_ring_start; -unsigned int led_duty; -unsigned int led_duty_step = 3; +unsigned long last_light_measure = 0; + +unsigned long touch_time[4] = {0, 0, 0, 0}; +unsigned long last_touch_measure = 0; // Bytewise reverse unsigned char reverse(unsigned char b) { @@ -85,19 +58,11 @@ unsigned char fix_pixels(unsigned char b) { } void shift_matrix() { - if(led_duty_step == 0) { - digitalWrite(PIN_REG_LATCH, LOW); - shiftOut(PIN_REG_DATA, PIN_REG_CLOCK, MSBFIRST, ~(1 << matrix_row_on)); - shiftOut(PIN_REG_DATA, PIN_REG_CLOCK, MSBFIRST, fix_pixels(matrix[(matrix_row_on+7)%8])); - digitalWrite(PIN_REG_LATCH, HIGH); - matrix_row_on = (matrix_row_on + 1) % 8; - } else if(led_duty_step == 1) { - digitalWrite(PIN_REG_LATCH, LOW); - shiftOut(PIN_REG_DATA, PIN_REG_CLOCK, MSBFIRST, 255); - shiftOut(PIN_REG_DATA, PIN_REG_CLOCK, MSBFIRST, 0); - digitalWrite(PIN_REG_LATCH, HIGH); - } - led_duty_step ++; + digitalWrite(PIN_REG_LATCH, LOW); + shiftOut(PIN_REG_DATA, PIN_REG_CLOCK, MSBFIRST, ~(1 << matrix_row_on)); + shiftOut(PIN_REG_DATA, PIN_REG_CLOCK, MSBFIRST, fix_pixels(matrix[(matrix_row_on+7)%8])); + digitalWrite(PIN_REG_LATCH, HIGH); + matrix_row_on = (matrix_row_on + 1) % 8; } void draw_time(unsigned long t) { @@ -146,10 +111,9 @@ void setup() { pinMode(PIN_REG_DATA, OUTPUT); pinMode(PIN_REG_CLOCK, OUTPUT); pinMode(PIN_REG_LATCH, OUTPUT); - pinMode(PIN_BUZZER, OUTPUT); + pinMode(PIN_BUZZER_QUIET, OUTPUT); + pinMode(PIN_BUZZER_LOUD, OUTPUT); pinMode(PIN_BUTTON, INPUT_PULLUP); - pinMode(PIN_LED_DUTY, INPUT); - irrecv.enableIRIn(); pinMode(13, OUTPUT); digitalWrite(13, LOW); @@ -160,49 +124,68 @@ void setup() { } void loop() { - if(led_duty_step > led_duty) { - led_duty_step = 0; - led_duty = (1023-analogRead(PIN_LED_DUTY)) / 128; - } - - if(irrecv.decode(&ircode)) { - #if SERIAL_DEBUG - send_hex(ircode.value); - #endif - unsigned long val = ircode.value; - if(val == last_ir) { - alarm_ringing = false; - switch(val) { - case AMP2540_VCDAUX: mode = (mode+1) % 3; break; - case AMP2540_VP: change_selected_number(1); break; - case AMP2540_VM: change_selected_number(-1); break; - case AMP2540_SEARCH: number_selection = (number_selection+1) % 4; break; - case AMP2540_TUNERCD: alarm = !alarm; break; - } - last_ir = 0; - } else { - last_ir = val; + #if SERIAL_DEBUG + send_hex(touch_0.capacitiveSensor(10)); + send_hex(touch_1.capacitiveSensor(10)); + send_hex(touch_2.capacitiveSensor(10)); + send_hex(touch_3.capacitiveSensor(10)); + delay(100); + #endif + + // Calibrate the thresholds according to your resistors + if(millis() > last_touch_measure + 50) { + if(touch_0.capacitiveSensor(10) > 127 && millis() > touch_time[0] + 250) { + touch_time[0] = millis(); + mode = (mode+1) % 3; } - irrecv.resume(); + if(touch_1.capacitiveSensor(10) > 127 && millis() > touch_time[1] + 250) { + touch_time[1] = millis(); + number_selection = (number_selection+1) % 4; + } + if(touch_2.capacitiveSensor(10) > 32 && millis() > touch_time[2] + 200) { + touch_time[2] = millis(); + change_selected_number(1); + } + if(touch_3.capacitiveSensor(10) > 32 && millis() > touch_time[3] + 200) { + touch_time[3] = millis(); + change_selected_number(-1); + } + last_touch_measure = millis(); } if(alarm && !alarm_ringing) { unsigned long t = ((millis() + time_offset) / 1000) % 86400; if(alarm_time / 1000 == t) { alarm_ringing = true; + alarm_ring_start = millis(); } } if(alarm_ringing) { - if(millis()%1000 < 100) { - matrix[7] = 0b11111111; - digitalWrite(PIN_BUZZER, HIGH); + if(alarm_ring_start + 30000 > millis()) { + if(millis()%1000 < 100) { + matrix[7] = 0b11111111; + digitalWrite(PIN_BUZZER_LOUD, LOW); + digitalWrite(PIN_BUZZER_QUIET, HIGH); + } else { + matrix[7] = 0b10000001; + digitalWrite(PIN_BUZZER_LOUD, LOW); + digitalWrite(PIN_BUZZER_QUIET, LOW); + } } else { - matrix[7] = 0b10000001; - digitalWrite(PIN_BUZZER, LOW); + if(millis()%1000 < 100) { + matrix[7] = 0b11111111; + digitalWrite(PIN_BUZZER_LOUD, HIGH); + digitalWrite(PIN_BUZZER_QUIET, LOW); + } else { + matrix[7] = 0b10000001; + digitalWrite(PIN_BUZZER_LOUD, LOW); + digitalWrite(PIN_BUZZER_QUIET, LOW); + } } if(digitalRead(PIN_BUTTON) == LOW) { - digitalWrite(PIN_BUZZER, LOW); + digitalWrite(PIN_BUZZER_LOUD, LOW); + digitalWrite(PIN_BUZZER_QUIET, LOW); alarm_ringing = false; } } @@ -218,6 +201,9 @@ void loop() { void change_selected_number(signed int nb) { switch(mode) { + case MODE_NORMAL: + if(nb > 0) alarm = true; + else if(nb < 0) alarm = false; case MODE_SETTIME: change_time(&time_offset, nb); break; case MODE_SETALARM: change_time(&alarm_time, nb); break; }