attiny841 support & various improvments
This commit is contained in:
		@@ -14,7 +14,7 @@ default_envs = attiny841_debug
 | 
				
			|||||||
[env]
 | 
					[env]
 | 
				
			||||||
build_flags = -Wall
 | 
					build_flags = -Wall
 | 
				
			||||||
lib_deps = 
 | 
					lib_deps = 
 | 
				
			||||||
    Encoder
 | 
						paulstoffregen/Encoder@^1.4.4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[env:attiny85]
 | 
					[env:attiny85]
 | 
				
			||||||
build_type = release
 | 
					build_type = release
 | 
				
			||||||
@@ -24,11 +24,10 @@ framework = arduino
 | 
				
			|||||||
upload_protocol = usbtiny
 | 
					upload_protocol = usbtiny
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[env:attiny85_debug]
 | 
					[env:attiny85_debug]
 | 
				
			||||||
build_type = debug
 | 
					 | 
				
			||||||
extends = env:attiny85
 | 
					extends = env:attiny85
 | 
				
			||||||
 | 
					build_flags = -D __BUILD_DEBUG__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[env:attiny85_init_debug]
 | 
					[env:attiny85_init_debug]
 | 
				
			||||||
build_type = debug
 | 
					 | 
				
			||||||
extends = env:attiny85_debug
 | 
					extends = env:attiny85_debug
 | 
				
			||||||
build_flags = -D DEBUG_INIT
 | 
					build_flags = -D DEBUG_INIT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -38,8 +37,6 @@ platform = atmelavr
 | 
				
			|||||||
board = attiny841
 | 
					board = attiny841
 | 
				
			||||||
framework = arduino
 | 
					framework = arduino
 | 
				
			||||||
upload_protocol = usbtiny
 | 
					upload_protocol = usbtiny
 | 
				
			||||||
; default is 42 which divides by 8 internal clock to wich gives a system clock of 1MHz
 | 
					 | 
				
			||||||
; whith C2 we do not divide and system runs at 8MHz
 | 
					 | 
				
			||||||
board_build.f_cpu = 8000000L
 | 
					board_build.f_cpu = 8000000L
 | 
				
			||||||
board_fuses.lfuse = 0xC2
 | 
					board_fuses.lfuse = 0xC2
 | 
				
			||||||
board_fuses.hfuse = 0xDF
 | 
					board_fuses.hfuse = 0xDF
 | 
				
			||||||
@@ -47,13 +44,18 @@ board_fuses.efuse = 0xFF
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[env:attiny841_debug]
 | 
					[env:attiny841_debug]
 | 
				
			||||||
extends = env:attiny841
 | 
					extends = env:attiny841
 | 
				
			||||||
build_flags = -D DEBUG_INIT -D __BUILD_DEBUG__
 | 
					build_flags = -D __BUILD_DEBUG__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[env:uno]
 | 
					[env:uno]
 | 
				
			||||||
build_type = debug
 | 
					build_type = debug
 | 
				
			||||||
lib_deps =
 | 
					lib_deps =
 | 
				
			||||||
 | 
						${env.lib_deps}
 | 
				
			||||||
	Adafruit NeoPixel
 | 
						Adafruit NeoPixel
 | 
				
			||||||
platform = atmelavr
 | 
					platform = atmelavr
 | 
				
			||||||
board = uno
 | 
					board = uno
 | 
				
			||||||
framework = arduino
 | 
					framework = arduino
 | 
				
			||||||
build_flags = -D DEBUG
 | 
					build_flags = -D __BUILD_DEBUG__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[env:uno_analog]
 | 
				
			||||||
 | 
					extends = env:uno
 | 
				
			||||||
 | 
					build_flags = ${env:uno.build_flags} -D ANALOG_BUTTON
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2422
									
								
								schematics/attiny841/attiny841.kicad_pcb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2422
									
								
								schematics/attiny841/attiny841.kicad_pcb
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										83
									
								
								schematics/attiny841/attiny841.kicad_prl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								schematics/attiny841/attiny841.kicad_prl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "board": {
 | 
				
			||||||
 | 
					    "active_layer": 0,
 | 
				
			||||||
 | 
					    "active_layer_preset": "All Layers",
 | 
				
			||||||
 | 
					    "auto_track_width": true,
 | 
				
			||||||
 | 
					    "hidden_netclasses": [],
 | 
				
			||||||
 | 
					    "hidden_nets": [],
 | 
				
			||||||
 | 
					    "high_contrast_mode": 0,
 | 
				
			||||||
 | 
					    "net_color_mode": 1,
 | 
				
			||||||
 | 
					    "opacity": {
 | 
				
			||||||
 | 
					      "images": 0.6,
 | 
				
			||||||
 | 
					      "pads": 1.0,
 | 
				
			||||||
 | 
					      "tracks": 1.0,
 | 
				
			||||||
 | 
					      "vias": 1.0,
 | 
				
			||||||
 | 
					      "zones": 0.6
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "selection_filter": {
 | 
				
			||||||
 | 
					      "dimensions": true,
 | 
				
			||||||
 | 
					      "footprints": true,
 | 
				
			||||||
 | 
					      "graphics": true,
 | 
				
			||||||
 | 
					      "keepouts": true,
 | 
				
			||||||
 | 
					      "lockedItems": false,
 | 
				
			||||||
 | 
					      "otherItems": true,
 | 
				
			||||||
 | 
					      "pads": true,
 | 
				
			||||||
 | 
					      "text": true,
 | 
				
			||||||
 | 
					      "tracks": true,
 | 
				
			||||||
 | 
					      "vias": true,
 | 
				
			||||||
 | 
					      "zones": true
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "visible_items": [
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      1,
 | 
				
			||||||
 | 
					      2,
 | 
				
			||||||
 | 
					      3,
 | 
				
			||||||
 | 
					      4,
 | 
				
			||||||
 | 
					      5,
 | 
				
			||||||
 | 
					      8,
 | 
				
			||||||
 | 
					      9,
 | 
				
			||||||
 | 
					      10,
 | 
				
			||||||
 | 
					      11,
 | 
				
			||||||
 | 
					      12,
 | 
				
			||||||
 | 
					      13,
 | 
				
			||||||
 | 
					      15,
 | 
				
			||||||
 | 
					      16,
 | 
				
			||||||
 | 
					      17,
 | 
				
			||||||
 | 
					      18,
 | 
				
			||||||
 | 
					      19,
 | 
				
			||||||
 | 
					      20,
 | 
				
			||||||
 | 
					      21,
 | 
				
			||||||
 | 
					      22,
 | 
				
			||||||
 | 
					      23,
 | 
				
			||||||
 | 
					      24,
 | 
				
			||||||
 | 
					      25,
 | 
				
			||||||
 | 
					      26,
 | 
				
			||||||
 | 
					      27,
 | 
				
			||||||
 | 
					      28,
 | 
				
			||||||
 | 
					      29,
 | 
				
			||||||
 | 
					      30,
 | 
				
			||||||
 | 
					      32,
 | 
				
			||||||
 | 
					      33,
 | 
				
			||||||
 | 
					      34,
 | 
				
			||||||
 | 
					      35,
 | 
				
			||||||
 | 
					      36,
 | 
				
			||||||
 | 
					      39,
 | 
				
			||||||
 | 
					      40
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "visible_layers": "fffffff_ffffffff",
 | 
				
			||||||
 | 
					    "zone_display_mode": 0
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "git": {
 | 
				
			||||||
 | 
					    "repo_password": "",
 | 
				
			||||||
 | 
					    "repo_type": "",
 | 
				
			||||||
 | 
					    "repo_username": "",
 | 
				
			||||||
 | 
					    "ssh_key": ""
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "meta": {
 | 
				
			||||||
 | 
					    "filename": "attiny841.kicad_prl",
 | 
				
			||||||
 | 
					    "version": 3
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "project": {
 | 
				
			||||||
 | 
					    "files": []
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										584
									
								
								schematics/attiny841/attiny841.kicad_pro
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										584
									
								
								schematics/attiny841/attiny841.kicad_pro
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,584 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "board": {
 | 
				
			||||||
 | 
					    "3dviewports": [],
 | 
				
			||||||
 | 
					    "design_settings": {
 | 
				
			||||||
 | 
					      "defaults": {
 | 
				
			||||||
 | 
					        "apply_defaults_to_fp_fields": false,
 | 
				
			||||||
 | 
					        "apply_defaults_to_fp_shapes": false,
 | 
				
			||||||
 | 
					        "apply_defaults_to_fp_text": false,
 | 
				
			||||||
 | 
					        "board_outline_line_width": 0.05,
 | 
				
			||||||
 | 
					        "copper_line_width": 0.2,
 | 
				
			||||||
 | 
					        "copper_text_italic": false,
 | 
				
			||||||
 | 
					        "copper_text_size_h": 1.5,
 | 
				
			||||||
 | 
					        "copper_text_size_v": 1.5,
 | 
				
			||||||
 | 
					        "copper_text_thickness": 0.3,
 | 
				
			||||||
 | 
					        "copper_text_upright": false,
 | 
				
			||||||
 | 
					        "courtyard_line_width": 0.05,
 | 
				
			||||||
 | 
					        "dimension_precision": 4,
 | 
				
			||||||
 | 
					        "dimension_units": 3,
 | 
				
			||||||
 | 
					        "dimensions": {
 | 
				
			||||||
 | 
					          "arrow_length": 1270000,
 | 
				
			||||||
 | 
					          "extension_offset": 500000,
 | 
				
			||||||
 | 
					          "keep_text_aligned": true,
 | 
				
			||||||
 | 
					          "suppress_zeroes": false,
 | 
				
			||||||
 | 
					          "text_position": 0,
 | 
				
			||||||
 | 
					          "units_format": 1
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "fab_line_width": 0.1,
 | 
				
			||||||
 | 
					        "fab_text_italic": false,
 | 
				
			||||||
 | 
					        "fab_text_size_h": 1.0,
 | 
				
			||||||
 | 
					        "fab_text_size_v": 1.0,
 | 
				
			||||||
 | 
					        "fab_text_thickness": 0.15,
 | 
				
			||||||
 | 
					        "fab_text_upright": false,
 | 
				
			||||||
 | 
					        "other_line_width": 0.1,
 | 
				
			||||||
 | 
					        "other_text_italic": false,
 | 
				
			||||||
 | 
					        "other_text_size_h": 1.0,
 | 
				
			||||||
 | 
					        "other_text_size_v": 1.0,
 | 
				
			||||||
 | 
					        "other_text_thickness": 0.15,
 | 
				
			||||||
 | 
					        "other_text_upright": false,
 | 
				
			||||||
 | 
					        "pads": {
 | 
				
			||||||
 | 
					          "drill": 0.762,
 | 
				
			||||||
 | 
					          "height": 1.524,
 | 
				
			||||||
 | 
					          "width": 1.524
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "silk_line_width": 0.1,
 | 
				
			||||||
 | 
					        "silk_text_italic": false,
 | 
				
			||||||
 | 
					        "silk_text_size_h": 1.0,
 | 
				
			||||||
 | 
					        "silk_text_size_v": 1.0,
 | 
				
			||||||
 | 
					        "silk_text_thickness": 0.1,
 | 
				
			||||||
 | 
					        "silk_text_upright": false,
 | 
				
			||||||
 | 
					        "zones": {
 | 
				
			||||||
 | 
					          "min_clearance": 0.5
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "diff_pair_dimensions": [],
 | 
				
			||||||
 | 
					      "drc_exclusions": [],
 | 
				
			||||||
 | 
					      "meta": {
 | 
				
			||||||
 | 
					        "version": 2
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "rule_severities": {
 | 
				
			||||||
 | 
					        "annular_width": "error",
 | 
				
			||||||
 | 
					        "clearance": "error",
 | 
				
			||||||
 | 
					        "connection_width": "warning",
 | 
				
			||||||
 | 
					        "copper_edge_clearance": "error",
 | 
				
			||||||
 | 
					        "copper_sliver": "warning",
 | 
				
			||||||
 | 
					        "courtyards_overlap": "error",
 | 
				
			||||||
 | 
					        "diff_pair_gap_out_of_range": "error",
 | 
				
			||||||
 | 
					        "diff_pair_uncoupled_length_too_long": "error",
 | 
				
			||||||
 | 
					        "drill_out_of_range": "error",
 | 
				
			||||||
 | 
					        "duplicate_footprints": "warning",
 | 
				
			||||||
 | 
					        "extra_footprint": "warning",
 | 
				
			||||||
 | 
					        "footprint": "error",
 | 
				
			||||||
 | 
					        "footprint_symbol_mismatch": "warning",
 | 
				
			||||||
 | 
					        "footprint_type_mismatch": "ignore",
 | 
				
			||||||
 | 
					        "hole_clearance": "error",
 | 
				
			||||||
 | 
					        "hole_near_hole": "error",
 | 
				
			||||||
 | 
					        "holes_co_located": "warning",
 | 
				
			||||||
 | 
					        "invalid_outline": "error",
 | 
				
			||||||
 | 
					        "isolated_copper": "warning",
 | 
				
			||||||
 | 
					        "item_on_disabled_layer": "error",
 | 
				
			||||||
 | 
					        "items_not_allowed": "error",
 | 
				
			||||||
 | 
					        "length_out_of_range": "error",
 | 
				
			||||||
 | 
					        "lib_footprint_issues": "warning",
 | 
				
			||||||
 | 
					        "lib_footprint_mismatch": "warning",
 | 
				
			||||||
 | 
					        "malformed_courtyard": "error",
 | 
				
			||||||
 | 
					        "microvia_drill_out_of_range": "error",
 | 
				
			||||||
 | 
					        "missing_courtyard": "ignore",
 | 
				
			||||||
 | 
					        "missing_footprint": "warning",
 | 
				
			||||||
 | 
					        "net_conflict": "warning",
 | 
				
			||||||
 | 
					        "npth_inside_courtyard": "ignore",
 | 
				
			||||||
 | 
					        "padstack": "warning",
 | 
				
			||||||
 | 
					        "pth_inside_courtyard": "ignore",
 | 
				
			||||||
 | 
					        "shorting_items": "error",
 | 
				
			||||||
 | 
					        "silk_edge_clearance": "warning",
 | 
				
			||||||
 | 
					        "silk_over_copper": "warning",
 | 
				
			||||||
 | 
					        "silk_overlap": "warning",
 | 
				
			||||||
 | 
					        "skew_out_of_range": "error",
 | 
				
			||||||
 | 
					        "solder_mask_bridge": "error",
 | 
				
			||||||
 | 
					        "starved_thermal": "error",
 | 
				
			||||||
 | 
					        "text_height": "warning",
 | 
				
			||||||
 | 
					        "text_thickness": "warning",
 | 
				
			||||||
 | 
					        "through_hole_pad_without_hole": "error",
 | 
				
			||||||
 | 
					        "too_many_vias": "error",
 | 
				
			||||||
 | 
					        "track_dangling": "warning",
 | 
				
			||||||
 | 
					        "track_width": "error",
 | 
				
			||||||
 | 
					        "tracks_crossing": "error",
 | 
				
			||||||
 | 
					        "unconnected_items": "error",
 | 
				
			||||||
 | 
					        "unresolved_variable": "error",
 | 
				
			||||||
 | 
					        "via_dangling": "warning",
 | 
				
			||||||
 | 
					        "zones_intersect": "error"
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "rules": {
 | 
				
			||||||
 | 
					        "max_error": 0.005,
 | 
				
			||||||
 | 
					        "min_clearance": 0.0,
 | 
				
			||||||
 | 
					        "min_connection": 0.0,
 | 
				
			||||||
 | 
					        "min_copper_edge_clearance": 0.5,
 | 
				
			||||||
 | 
					        "min_hole_clearance": 0.25,
 | 
				
			||||||
 | 
					        "min_hole_to_hole": 0.25,
 | 
				
			||||||
 | 
					        "min_microvia_diameter": 0.2,
 | 
				
			||||||
 | 
					        "min_microvia_drill": 0.1,
 | 
				
			||||||
 | 
					        "min_resolved_spokes": 2,
 | 
				
			||||||
 | 
					        "min_silk_clearance": 0.0,
 | 
				
			||||||
 | 
					        "min_text_height": 0.8,
 | 
				
			||||||
 | 
					        "min_text_thickness": 0.08,
 | 
				
			||||||
 | 
					        "min_through_hole_diameter": 0.3,
 | 
				
			||||||
 | 
					        "min_track_width": 0.0,
 | 
				
			||||||
 | 
					        "min_via_annular_width": 0.1,
 | 
				
			||||||
 | 
					        "min_via_diameter": 0.5,
 | 
				
			||||||
 | 
					        "solder_mask_to_copper_clearance": 0.0,
 | 
				
			||||||
 | 
					        "use_height_for_length_calcs": true
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "teardrop_options": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "td_onpadsmd": true,
 | 
				
			||||||
 | 
					          "td_onroundshapesonly": false,
 | 
				
			||||||
 | 
					          "td_ontrackend": false,
 | 
				
			||||||
 | 
					          "td_onviapad": true
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      "teardrop_parameters": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "td_allow_use_two_tracks": true,
 | 
				
			||||||
 | 
					          "td_curve_segcount": 0,
 | 
				
			||||||
 | 
					          "td_height_ratio": 1.0,
 | 
				
			||||||
 | 
					          "td_length_ratio": 0.5,
 | 
				
			||||||
 | 
					          "td_maxheight": 2.0,
 | 
				
			||||||
 | 
					          "td_maxlen": 1.0,
 | 
				
			||||||
 | 
					          "td_on_pad_in_zone": false,
 | 
				
			||||||
 | 
					          "td_target_name": "td_round_shape",
 | 
				
			||||||
 | 
					          "td_width_to_size_filter_ratio": 0.9
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "td_allow_use_two_tracks": true,
 | 
				
			||||||
 | 
					          "td_curve_segcount": 0,
 | 
				
			||||||
 | 
					          "td_height_ratio": 1.0,
 | 
				
			||||||
 | 
					          "td_length_ratio": 0.5,
 | 
				
			||||||
 | 
					          "td_maxheight": 2.0,
 | 
				
			||||||
 | 
					          "td_maxlen": 1.0,
 | 
				
			||||||
 | 
					          "td_on_pad_in_zone": false,
 | 
				
			||||||
 | 
					          "td_target_name": "td_rect_shape",
 | 
				
			||||||
 | 
					          "td_width_to_size_filter_ratio": 0.9
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "td_allow_use_two_tracks": true,
 | 
				
			||||||
 | 
					          "td_curve_segcount": 0,
 | 
				
			||||||
 | 
					          "td_height_ratio": 1.0,
 | 
				
			||||||
 | 
					          "td_length_ratio": 0.5,
 | 
				
			||||||
 | 
					          "td_maxheight": 2.0,
 | 
				
			||||||
 | 
					          "td_maxlen": 1.0,
 | 
				
			||||||
 | 
					          "td_on_pad_in_zone": false,
 | 
				
			||||||
 | 
					          "td_target_name": "td_track_end",
 | 
				
			||||||
 | 
					          "td_width_to_size_filter_ratio": 0.9
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      "track_widths": [],
 | 
				
			||||||
 | 
					      "tuning_pattern_settings": {
 | 
				
			||||||
 | 
					        "diff_pair_defaults": {
 | 
				
			||||||
 | 
					          "corner_radius_percentage": 80,
 | 
				
			||||||
 | 
					          "corner_style": 1,
 | 
				
			||||||
 | 
					          "max_amplitude": 1.0,
 | 
				
			||||||
 | 
					          "min_amplitude": 0.2,
 | 
				
			||||||
 | 
					          "single_sided": false,
 | 
				
			||||||
 | 
					          "spacing": 1.0
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "diff_pair_skew_defaults": {
 | 
				
			||||||
 | 
					          "corner_radius_percentage": 80,
 | 
				
			||||||
 | 
					          "corner_style": 1,
 | 
				
			||||||
 | 
					          "max_amplitude": 1.0,
 | 
				
			||||||
 | 
					          "min_amplitude": 0.2,
 | 
				
			||||||
 | 
					          "single_sided": false,
 | 
				
			||||||
 | 
					          "spacing": 0.6
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "single_track_defaults": {
 | 
				
			||||||
 | 
					          "corner_radius_percentage": 80,
 | 
				
			||||||
 | 
					          "corner_style": 1,
 | 
				
			||||||
 | 
					          "max_amplitude": 1.0,
 | 
				
			||||||
 | 
					          "min_amplitude": 0.2,
 | 
				
			||||||
 | 
					          "single_sided": false,
 | 
				
			||||||
 | 
					          "spacing": 0.6
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "via_dimensions": [],
 | 
				
			||||||
 | 
					      "zones_allow_external_fillets": false
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "ipc2581": {
 | 
				
			||||||
 | 
					      "dist": "",
 | 
				
			||||||
 | 
					      "distpn": "",
 | 
				
			||||||
 | 
					      "internal_id": "",
 | 
				
			||||||
 | 
					      "mfg": "",
 | 
				
			||||||
 | 
					      "mpn": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "layer_presets": [],
 | 
				
			||||||
 | 
					    "viewports": []
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "boards": [],
 | 
				
			||||||
 | 
					  "cvpcb": {
 | 
				
			||||||
 | 
					    "equivalence_files": []
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "erc": {
 | 
				
			||||||
 | 
					    "erc_exclusions": [],
 | 
				
			||||||
 | 
					    "meta": {
 | 
				
			||||||
 | 
					      "version": 0
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "pin_map": [
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        1,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        0,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      [
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2,
 | 
				
			||||||
 | 
					        2
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "rule_severities": {
 | 
				
			||||||
 | 
					      "bus_definition_conflict": "error",
 | 
				
			||||||
 | 
					      "bus_entry_needed": "error",
 | 
				
			||||||
 | 
					      "bus_to_bus_conflict": "error",
 | 
				
			||||||
 | 
					      "bus_to_net_conflict": "error",
 | 
				
			||||||
 | 
					      "conflicting_netclasses": "error",
 | 
				
			||||||
 | 
					      "different_unit_footprint": "error",
 | 
				
			||||||
 | 
					      "different_unit_net": "error",
 | 
				
			||||||
 | 
					      "duplicate_reference": "error",
 | 
				
			||||||
 | 
					      "duplicate_sheet_names": "error",
 | 
				
			||||||
 | 
					      "endpoint_off_grid": "warning",
 | 
				
			||||||
 | 
					      "extra_units": "error",
 | 
				
			||||||
 | 
					      "global_label_dangling": "warning",
 | 
				
			||||||
 | 
					      "hier_label_mismatch": "error",
 | 
				
			||||||
 | 
					      "label_dangling": "error",
 | 
				
			||||||
 | 
					      "lib_symbol_issues": "warning",
 | 
				
			||||||
 | 
					      "missing_bidi_pin": "warning",
 | 
				
			||||||
 | 
					      "missing_input_pin": "warning",
 | 
				
			||||||
 | 
					      "missing_power_pin": "error",
 | 
				
			||||||
 | 
					      "missing_unit": "warning",
 | 
				
			||||||
 | 
					      "multiple_net_names": "warning",
 | 
				
			||||||
 | 
					      "net_not_bus_member": "warning",
 | 
				
			||||||
 | 
					      "no_connect_connected": "warning",
 | 
				
			||||||
 | 
					      "no_connect_dangling": "warning",
 | 
				
			||||||
 | 
					      "pin_not_connected": "error",
 | 
				
			||||||
 | 
					      "pin_not_driven": "error",
 | 
				
			||||||
 | 
					      "pin_to_pin": "warning",
 | 
				
			||||||
 | 
					      "power_pin_not_driven": "error",
 | 
				
			||||||
 | 
					      "similar_labels": "warning",
 | 
				
			||||||
 | 
					      "simulation_model_issue": "ignore",
 | 
				
			||||||
 | 
					      "unannotated": "error",
 | 
				
			||||||
 | 
					      "unit_value_mismatch": "error",
 | 
				
			||||||
 | 
					      "unresolved_variable": "error",
 | 
				
			||||||
 | 
					      "wire_dangling": "error"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "libraries": {
 | 
				
			||||||
 | 
					    "pinned_footprint_libs": [],
 | 
				
			||||||
 | 
					    "pinned_symbol_libs": []
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "meta": {
 | 
				
			||||||
 | 
					    "filename": "attiny841.kicad_pro",
 | 
				
			||||||
 | 
					    "version": 1
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "net_settings": {
 | 
				
			||||||
 | 
					    "classes": [
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "bus_width": 12,
 | 
				
			||||||
 | 
					        "clearance": 0.2,
 | 
				
			||||||
 | 
					        "diff_pair_gap": 0.25,
 | 
				
			||||||
 | 
					        "diff_pair_via_gap": 0.25,
 | 
				
			||||||
 | 
					        "diff_pair_width": 0.2,
 | 
				
			||||||
 | 
					        "line_style": 0,
 | 
				
			||||||
 | 
					        "microvia_diameter": 0.3,
 | 
				
			||||||
 | 
					        "microvia_drill": 0.1,
 | 
				
			||||||
 | 
					        "name": "Default",
 | 
				
			||||||
 | 
					        "pcb_color": "rgba(0, 0, 0, 0.000)",
 | 
				
			||||||
 | 
					        "schematic_color": "rgba(0, 0, 0, 0.000)",
 | 
				
			||||||
 | 
					        "track_width": 0.2,
 | 
				
			||||||
 | 
					        "via_diameter": 0.6,
 | 
				
			||||||
 | 
					        "via_drill": 0.3,
 | 
				
			||||||
 | 
					        "wire_width": 6
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "meta": {
 | 
				
			||||||
 | 
					      "version": 3
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "net_colors": null,
 | 
				
			||||||
 | 
					    "netclass_assignments": null,
 | 
				
			||||||
 | 
					    "netclass_patterns": []
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "pcbnew": {
 | 
				
			||||||
 | 
					    "last_paths": {
 | 
				
			||||||
 | 
					      "gencad": "",
 | 
				
			||||||
 | 
					      "idf": "",
 | 
				
			||||||
 | 
					      "netlist": "",
 | 
				
			||||||
 | 
					      "plot": "",
 | 
				
			||||||
 | 
					      "pos_files": "",
 | 
				
			||||||
 | 
					      "specctra_dsn": "",
 | 
				
			||||||
 | 
					      "step": "",
 | 
				
			||||||
 | 
					      "svg": "",
 | 
				
			||||||
 | 
					      "vrml": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "page_layout_descr_file": ""
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "schematic": {
 | 
				
			||||||
 | 
					    "annotate_start_num": 0,
 | 
				
			||||||
 | 
					    "bom_export_filename": "",
 | 
				
			||||||
 | 
					    "bom_fmt_presets": [],
 | 
				
			||||||
 | 
					    "bom_fmt_settings": {
 | 
				
			||||||
 | 
					      "field_delimiter": ",",
 | 
				
			||||||
 | 
					      "keep_line_breaks": false,
 | 
				
			||||||
 | 
					      "keep_tabs": false,
 | 
				
			||||||
 | 
					      "name": "CSV",
 | 
				
			||||||
 | 
					      "ref_delimiter": ",",
 | 
				
			||||||
 | 
					      "ref_range_delimiter": "",
 | 
				
			||||||
 | 
					      "string_delimiter": "\""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "bom_presets": [],
 | 
				
			||||||
 | 
					    "bom_settings": {
 | 
				
			||||||
 | 
					      "exclude_dnp": false,
 | 
				
			||||||
 | 
					      "fields_ordered": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "group_by": false,
 | 
				
			||||||
 | 
					          "label": "Reference",
 | 
				
			||||||
 | 
					          "name": "Reference",
 | 
				
			||||||
 | 
					          "show": true
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "group_by": true,
 | 
				
			||||||
 | 
					          "label": "Value",
 | 
				
			||||||
 | 
					          "name": "Value",
 | 
				
			||||||
 | 
					          "show": true
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "group_by": false,
 | 
				
			||||||
 | 
					          "label": "Datasheet",
 | 
				
			||||||
 | 
					          "name": "Datasheet",
 | 
				
			||||||
 | 
					          "show": true
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "group_by": false,
 | 
				
			||||||
 | 
					          "label": "Footprint",
 | 
				
			||||||
 | 
					          "name": "Footprint",
 | 
				
			||||||
 | 
					          "show": true
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "group_by": false,
 | 
				
			||||||
 | 
					          "label": "Qty",
 | 
				
			||||||
 | 
					          "name": "${QUANTITY}",
 | 
				
			||||||
 | 
					          "show": true
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "group_by": true,
 | 
				
			||||||
 | 
					          "label": "DNP",
 | 
				
			||||||
 | 
					          "name": "${DNP}",
 | 
				
			||||||
 | 
					          "show": true
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      "filter_string": "",
 | 
				
			||||||
 | 
					      "group_symbols": true,
 | 
				
			||||||
 | 
					      "name": "Grouped By Value",
 | 
				
			||||||
 | 
					      "sort_asc": true,
 | 
				
			||||||
 | 
					      "sort_field": "Reference"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "connection_grid_size": 50.0,
 | 
				
			||||||
 | 
					    "drawing": {
 | 
				
			||||||
 | 
					      "dashed_lines_dash_length_ratio": 12.0,
 | 
				
			||||||
 | 
					      "dashed_lines_gap_length_ratio": 3.0,
 | 
				
			||||||
 | 
					      "default_line_thickness": 6.0,
 | 
				
			||||||
 | 
					      "default_text_size": 50.0,
 | 
				
			||||||
 | 
					      "field_names": [],
 | 
				
			||||||
 | 
					      "intersheets_ref_own_page": false,
 | 
				
			||||||
 | 
					      "intersheets_ref_prefix": "",
 | 
				
			||||||
 | 
					      "intersheets_ref_short": false,
 | 
				
			||||||
 | 
					      "intersheets_ref_show": false,
 | 
				
			||||||
 | 
					      "intersheets_ref_suffix": "",
 | 
				
			||||||
 | 
					      "junction_size_choice": 3,
 | 
				
			||||||
 | 
					      "label_size_ratio": 0.375,
 | 
				
			||||||
 | 
					      "operating_point_overlay_i_precision": 3,
 | 
				
			||||||
 | 
					      "operating_point_overlay_i_range": "~A",
 | 
				
			||||||
 | 
					      "operating_point_overlay_v_precision": 3,
 | 
				
			||||||
 | 
					      "operating_point_overlay_v_range": "~V",
 | 
				
			||||||
 | 
					      "overbar_offset_ratio": 1.23,
 | 
				
			||||||
 | 
					      "pin_symbol_size": 25.0,
 | 
				
			||||||
 | 
					      "text_offset_ratio": 0.15
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "legacy_lib_dir": "",
 | 
				
			||||||
 | 
					    "legacy_lib_list": [],
 | 
				
			||||||
 | 
					    "meta": {
 | 
				
			||||||
 | 
					      "version": 1
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "net_format_name": "",
 | 
				
			||||||
 | 
					    "page_layout_descr_file": "",
 | 
				
			||||||
 | 
					    "plot_directory": "",
 | 
				
			||||||
 | 
					    "spice_current_sheet_as_root": false,
 | 
				
			||||||
 | 
					    "spice_external_command": "spice \"%I\"",
 | 
				
			||||||
 | 
					    "spice_model_current_sheet_as_root": true,
 | 
				
			||||||
 | 
					    "spice_save_all_currents": false,
 | 
				
			||||||
 | 
					    "spice_save_all_dissipations": false,
 | 
				
			||||||
 | 
					    "spice_save_all_voltages": false,
 | 
				
			||||||
 | 
					    "subpart_first_id": 65,
 | 
				
			||||||
 | 
					    "subpart_id_separator": 0
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "sheets": [
 | 
				
			||||||
 | 
					    [
 | 
				
			||||||
 | 
					      "cb328b30-5a48-4e50-af91-429e48189072",
 | 
				
			||||||
 | 
					      "Root"
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "text_variables": {}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										3180
									
								
								schematics/attiny841/attiny841.kicad_sch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3180
									
								
								schematics/attiny841/attiny841.kicad_sch
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										99352
									
								
								schematics/attiny841/fp-info-cache
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99352
									
								
								schematics/attiny841/fp-info-cache
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								schematics/attiny_841.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								schematics/attiny_841.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -2,9 +2,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <Arduino.h>
 | 
					#include <Arduino.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "global.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Button::setup(void) { pinMode(_pin, INPUT_PULLUP); }
 | 
					void Button::setup(void) { pinMode(_pin, INPUT_PULLUP); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Button::is_button_pressed(void) { return digitalRead(_pin) == 0; }
 | 
					bool Button::is_pressed(void) { return digitalRead(_pin) == 0; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AnalogButton::setup(void) {
 | 
					void AnalogButton::setup(void) {
 | 
				
			||||||
  if (_vRef < 0) {
 | 
					  if (_vRef < 0) {
 | 
				
			||||||
@@ -17,8 +19,9 @@ bool AnalogButton::is_button_pressed(void) { return analogRead(_pin) < _vRef; }
 | 
				
			|||||||
void AnalogButton::calibrate(void) {
 | 
					void AnalogButton::calibrate(void) {
 | 
				
			||||||
  int highRef, lowRef;
 | 
					  int highRef, lowRef;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__BUILD_DEBUG__) && false
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
  debugSerial.print(__func__);
 | 
					  debugSerial.println(__func__);
 | 
				
			||||||
 | 
					  debugSerial.println("Getting high ref > 1000");
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Get the button released (High) state voltage, should be close to 1024 (analogRead max) */
 | 
					  /* Get the button released (High) state voltage, should be close to 1024 (analogRead max) */
 | 
				
			||||||
@@ -27,23 +30,28 @@ void AnalogButton::calibrate(void) {
 | 
				
			|||||||
    delay(300);
 | 
					    delay(300);
 | 
				
			||||||
  } while (highRef < 1000);
 | 
					  } while (highRef < 1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__BUILD_DEBUG__) && false
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
  debugSerial.println("highRef=");
 | 
					  debugSerial.print("highRef=");
 | 
				
			||||||
  debugSerial.println(highRef);
 | 
					  debugSerial.println(highRef);
 | 
				
			||||||
 | 
					  debugSerial.print("Getting low ref < ");
 | 
				
			||||||
 | 
					  debugSerial.println(highRef - 50);
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Get the button pushed (Low) state voltage (min of ~5% difference needed to avoid false detection) */
 | 
					  /* Get the button pushed (Low) state voltage (min of ~5% difference needed to avoid false detection) */
 | 
				
			||||||
  lowRef = analogRead(_pin);
 | 
					  do {
 | 
				
			||||||
  while (highRef - lowRef < 50) {
 | 
					 | 
				
			||||||
    lowRef = analogRead(_pin);
 | 
					    lowRef = analogRead(_pin);
 | 
				
			||||||
    delay(300);
 | 
					    delay(300);
 | 
				
			||||||
  }
 | 
					  } while (lowRef > highRef -  50);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__BUILD_DEBUG__) && false
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
  debugSerial.println("lowRef=");
 | 
					  debugSerial.println("lowRef=");
 | 
				
			||||||
  debugSerial.println(lowRef);
 | 
					  debugSerial.println(lowRef);
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Add ~1% tolerance */
 | 
					  /* Add ~1% tolerance */
 | 
				
			||||||
  _vRef = lowRef + 10;
 | 
					  _vRef = lowRef + 10;
 | 
				
			||||||
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
 | 
					  debugSerial.println("vRef=");
 | 
				
			||||||
 | 
					  debugSerial.println(_vRef);
 | 
				
			||||||
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ public:
 | 
				
			|||||||
  ~Button() {};
 | 
					  ~Button() {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void setup(void);
 | 
					  void setup(void);
 | 
				
			||||||
  bool is_button_pressed(void);
 | 
					  bool is_pressed(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
  uint8_t _pin;
 | 
					  uint8_t _pin;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,8 @@
 | 
				
			|||||||
#define __GLOBAL_HPP__
 | 
					#define __GLOBAL_HPP__
 | 
				
			||||||
#include <Arduino.h>
 | 
					#include <Arduino.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define LED_STRIP_LEGNTH 36
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* debug Serial definition */
 | 
					/* debug Serial definition */
 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
#if defined(ARDUINO_AVR_ATTINYX5)
 | 
					#if defined(ARDUINO_AVR_ATTINYX5)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
#include "led_strip.hpp"
 | 
					#include "led_strip.hpp"
 | 
				
			||||||
#include "global.hpp"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// LedStrip::LedStrip(/* args */) {}
 | 
					// LedStrip::LedStrip(/* args */) {}
 | 
				
			||||||
// LedStrip::~LedStrip() {}
 | 
					// LedStrip::~LedStrip() {}
 | 
				
			||||||
@@ -25,13 +24,90 @@ void LedStrip::fill(uint32_t c, uint16_t first, uint16_t count) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (i = first; i < end; i++) {
 | 
					  for (i = first; i < end; i++) {
 | 
				
			||||||
    setPixelColor(i, c);
 | 
					    this->setPixelColor(i, c);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint32_t tinyNeoPixel::ColorHSV(uint16_t hue, uint8_t sat, uint8_t val) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  uint8_t r, g, b;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Remap 0-65535 to 0-1529. Pure red is CENTERED on the 64K rollover;
 | 
				
			||||||
 | 
					   * 0 is not the start of pure red, but the midpoint...a few values above
 | 
				
			||||||
 | 
					   * zero and a few below 65536 all yield pure red (similarly, 32768 is the
 | 
				
			||||||
 | 
					   * midpoint, not start, of pure cyan). The 8-bit RGB hexcone (256 values
 | 
				
			||||||
 | 
					   * each for red, green, blue) really only allows for 1530 distinct hues
 | 
				
			||||||
 | 
					   * (not 1536, more on that below), but the full unsigned 16-bit type was
 | 
				
			||||||
 | 
					   * chosen for hue so that one's code can easily handle a contiguous color
 | 
				
			||||||
 | 
					   * wheel by allowing hue to roll over in either direction.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  hue = (hue * 1530L + 32768) / 65536;
 | 
				
			||||||
 | 
					  /* Because red is centered on the rollover point (the +32768 above,
 | 
				
			||||||
 | 
					   * essentially a fixed-point +0.5), the above actually yields 0 to 1530,
 | 
				
			||||||
 | 
					   * where 0 and 1530 would yield the same thing. Rather than apply a
 | 
				
			||||||
 | 
					   * costly modulo operator, 1530 is handled as a special case below.
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * So you'd think that the color "hexcone" (the thing that ramps from
 | 
				
			||||||
 | 
					   * pure red, to pure yellow, to pure green and so forth back to red,
 | 
				
			||||||
 | 
					   * yielding six slices), and with each color component having 256
 | 
				
			||||||
 | 
					   * possible values (0-255), might have 1536 possible items (6*256),
 | 
				
			||||||
 | 
					   * but in reality there's 1530. This is because the last element in
 | 
				
			||||||
 | 
					   * each 256-element slice is equal to the first element of the next
 | 
				
			||||||
 | 
					   * slice, and keeping those in there this would create small
 | 
				
			||||||
 | 
					   * discontinuities in the color wheel. So the last element of each
 | 
				
			||||||
 | 
					   * slice is dropped...we regard only elements 0-254, with item 255
 | 
				
			||||||
 | 
					   * being picked up as element 0 of the next slice. Like this:
 | 
				
			||||||
 | 
					   * Red to not-quite-pure-yellow is:        255,   0, 0 to 255, 254,   0
 | 
				
			||||||
 | 
					   * Pure yellow to not-quite-pure-green is: 255, 255, 0 to   1, 255,   0
 | 
				
			||||||
 | 
					   * Pure green to not-quite-pure-cyan is:     0, 255, 0 to   0, 255, 254
 | 
				
			||||||
 | 
					   * and so forth. Hence, 1530 distinct hues (0 to 1529), and hence why
 | 
				
			||||||
 | 
					   * the constants below are not the multiples of 256 you might expect.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  // Convert hue to R,G,B (nested ifs faster than divide+mod+switch):
 | 
				
			||||||
 | 
					  if (hue < 510) { // Red to Green-1
 | 
				
			||||||
 | 
					    b = 0;
 | 
				
			||||||
 | 
					    if (hue < 255) { //   Red to Yellow-1
 | 
				
			||||||
 | 
					      r = 255;
 | 
				
			||||||
 | 
					      g = hue;       //     g = 0 to 254
 | 
				
			||||||
 | 
					    } else {         //   Yellow to Green-1
 | 
				
			||||||
 | 
					      r = 510 - hue; //     r = 255 to 1
 | 
				
			||||||
 | 
					      g = 255;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } else if (hue < 1020) { // Green to Blue-1
 | 
				
			||||||
 | 
					    r = 0;
 | 
				
			||||||
 | 
					    if (hue < 765) { //   Green to Cyan-1
 | 
				
			||||||
 | 
					      g = 255;
 | 
				
			||||||
 | 
					      b = hue - 510;  //     b = 0 to 254
 | 
				
			||||||
 | 
					    } else {          //   Cyan to Blue-1
 | 
				
			||||||
 | 
					      g = 1020 - hue; //     g = 255 to 1
 | 
				
			||||||
 | 
					      b = 255;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } else if (hue < 1530) { // Blue to Red-1
 | 
				
			||||||
 | 
					    g = 0;
 | 
				
			||||||
 | 
					    if (hue < 1275) { //   Blue to Magenta-1
 | 
				
			||||||
 | 
					      r = hue - 1020; //     r = 0 to 254
 | 
				
			||||||
 | 
					      b = 255;
 | 
				
			||||||
 | 
					    } else { //   Magenta to Red-1
 | 
				
			||||||
 | 
					      r = 255;
 | 
				
			||||||
 | 
					      b = 1530 - hue; //     b = 255 to 1
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } else { // Last 0.5 Red (quicker than % operator)
 | 
				
			||||||
 | 
					    r = 255;
 | 
				
			||||||
 | 
					    g = b = 0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Apply saturation and value to R,G,B, pack into 32-bit result:
 | 
				
			||||||
 | 
					  uint32_t v1 = 1 + val;  // 1 to 256; allows >>8 instead of /255
 | 
				
			||||||
 | 
					  uint16_t s1 = 1 + sat;  // 1 to 256; same reason
 | 
				
			||||||
 | 
					  uint8_t s2 = 255 - sat; // 255 to 0
 | 
				
			||||||
 | 
					  return ((((((r * s1) >> 8) + s2) * v1) & 0xff00) << 8) | (((((g * s1) >> 8) + s2) * v1) & 0xff00) |
 | 
				
			||||||
 | 
					         (((((b * s1) >> 8) + s2) * v1) >> 8);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
 | 
					#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LedStrip::setup() {
 | 
					void LedStrip::setup(bool is_diag_mode) {
 | 
				
			||||||
  pinMode(LedPin, OUTPUT);
 | 
					  pinMode(LedPin, OUTPUT);
 | 
				
			||||||
 | 
					  if (is_diag_mode) {
 | 
				
			||||||
    setPixelColor(0, 255, 0, 0);
 | 
					    setPixelColor(0, 255, 0, 0);
 | 
				
			||||||
    fill(Color(45, 0, 0));
 | 
					    fill(Color(45, 0, 0));
 | 
				
			||||||
    show();
 | 
					    show();
 | 
				
			||||||
@@ -43,152 +119,193 @@ void LedStrip::setup() {
 | 
				
			|||||||
    show();
 | 
					    show();
 | 
				
			||||||
    delay(300);
 | 
					    delay(300);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  this->refresh();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void LedStrip::shiftHue(int shift) {
 | 
				
			||||||
 | 
					  hue += (shift << 11);
 | 
				
			||||||
 | 
					  /*             | encoder |  hue  | sat
 | 
				
			||||||
 | 
					   * values      |   20    | 65536 | 256
 | 
				
			||||||
 | 
					   * step        |    1    |  3277 |
 | 
				
			||||||
 | 
					   * shift       |    0    |    11 |   4
 | 
				
			||||||
 | 
					   * rounded     |         |  2048 |  16
 | 
				
			||||||
 | 
					   * total steps |         |    32 |  16
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
				
			||||||
 | 
					  if (shift != 0) {
 | 
				
			||||||
 | 
					    debugSerial.print(__func__);
 | 
				
			||||||
 | 
					    debugSerial.print(" : shift=");
 | 
				
			||||||
 | 
					    debugSerial.print(shift, DEC);
 | 
				
			||||||
 | 
					    debugSerial.print(", hue=");
 | 
				
			||||||
 | 
					    debugSerial.println(hue, DEC);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void LedStrip::shiftSaturation(int shift) {
 | 
				
			||||||
 | 
					  saturation += (shift << 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
				
			||||||
 | 
					  if (shift != 0) {
 | 
				
			||||||
 | 
					    debugSerial.print(__func__);
 | 
				
			||||||
 | 
					    debugSerial.print(" : shift=");
 | 
				
			||||||
 | 
					    debugSerial.print(shift, DEC);
 | 
				
			||||||
 | 
					    debugSerial.print(", saturation=");
 | 
				
			||||||
 | 
					    debugSerial.println(saturation, DEC);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void LedStrip::shiftBrightness(int shift) {
 | 
				
			||||||
 | 
					  brightness += (shift << 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
				
			||||||
 | 
					  if (shift != 0) {
 | 
				
			||||||
 | 
					    debugSerial.print(__func__);
 | 
				
			||||||
 | 
					    debugSerial.print(" : shift=");
 | 
				
			||||||
 | 
					    debugSerial.print(shift, DEC);
 | 
				
			||||||
 | 
					    debugSerial.print(", brightness=");
 | 
				
			||||||
 | 
					    debugSerial.println(brightness, DEC);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void LedStrip::shiftFirstLedOn(int shift) {
 | 
				
			||||||
 | 
					  if (shift > 0) {
 | 
				
			||||||
 | 
					    if (firstLedOn > LedCount) {
 | 
				
			||||||
 | 
					      firstLedOn = 0;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      ++firstLedOn;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    if (firstLedOn < 1) {
 | 
				
			||||||
 | 
					      firstLedOn = LedCount - 1;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      --firstLedOn;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
				
			||||||
 | 
					  if (shift != 0) {
 | 
				
			||||||
 | 
					    debugSerial.print(__func__);
 | 
				
			||||||
 | 
					    debugSerial.print(" : shift=");
 | 
				
			||||||
 | 
					    debugSerial.print(shift, DEC);
 | 
				
			||||||
 | 
					    debugSerial.print(", firstLedOn=");
 | 
				
			||||||
 | 
					    debugSerial.println(firstLedOn, DEC);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void LedStrip::shiftLedOnLenght(int shift) {
 | 
				
			||||||
 | 
					  if (shift > 0) {
 | 
				
			||||||
 | 
					    if (ledOnCount < LedCount) {
 | 
				
			||||||
 | 
					      ++ledOnCount;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      ledOnCount = 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    if (ledOnCount > 1) {
 | 
				
			||||||
 | 
					      --ledOnCount;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      ledOnCount = LedCount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
				
			||||||
 | 
					  if (shift != 0) {
 | 
				
			||||||
 | 
					    debugSerial.print(__func__);
 | 
				
			||||||
 | 
					    debugSerial.print(" : shift=");
 | 
				
			||||||
 | 
					    debugSerial.print(shift, DEC);
 | 
				
			||||||
 | 
					    debugSerial.print(", ledOnCount=");
 | 
				
			||||||
 | 
					    debugSerial.println(ledOnCount, DEC);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LedStrip::refresh() {
 | 
					void LedStrip::refresh() {
 | 
				
			||||||
  uint16_t const &ledOnMin = ledRingColorState.ledOnMin;
 | 
					  unsigned int lastLedOn = {firstLedOn + ledOnCount};
 | 
				
			||||||
  uint16_t const &ledOnMax = ledRingColorState.ledOnMax;
 | 
					  /* 0 <= Chunk 1 < x <= Chunk 2 < y <= Chunk 3 < ledcount*/
 | 
				
			||||||
  uint16_t LedOnCount = 0;
 | 
					  unsigned int chunk_index[4] = {0, 0, 0, LedCount};
 | 
				
			||||||
 | 
					  bool isChunkOn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
  debugSerial.print("Color hue,sat,bri=");
 | 
					  debugSerial.print("Color hue,sat,bri=");
 | 
				
			||||||
  debugSerial.print(ledRingColorState.hue);
 | 
					  debugSerial.print(this->hue);
 | 
				
			||||||
  debugSerial.print(",");
 | 
					  debugSerial.print(",");
 | 
				
			||||||
  debugSerial.print(ledRingColorState.saturation);
 | 
					  debugSerial.print(this->saturation);
 | 
				
			||||||
  debugSerial.print(",");
 | 
					  debugSerial.print(",");
 | 
				
			||||||
  debugSerial.println(ledRingColorState.brightness);
 | 
					  debugSerial.println(this->brightness);
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* reset ring */
 | 
					  /* reset ring */
 | 
				
			||||||
  fill();
 | 
					  // this->fill(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* compute number of led on */
 | 
					  if (lastLedOn < LedCount) {
 | 
				
			||||||
  if (ledOnMin <= ledOnMax) {
 | 
					    isChunkOn = false;
 | 
				
			||||||
    LedOnCount = ledOnMax - ledOnMin;
 | 
					    /* firstPhysicalLedOn */
 | 
				
			||||||
 | 
					    chunk_index[1] = firstLedOn;
 | 
				
			||||||
 | 
					    /* lastPhysicalLedOn */
 | 
				
			||||||
 | 
					    chunk_index[2] = chunk_index[1] + ledOnCount;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    LedOnCount = LedCount - (ledOnMax - ledOnMax);
 | 
					    isChunkOn = true;
 | 
				
			||||||
 | 
					    /* firstPhysicalLedOff */
 | 
				
			||||||
 | 
					    chunk_index[1] = firstLedOn + ledOnCount - LedCount;
 | 
				
			||||||
 | 
					    /* lastPhysicalLedOff */
 | 
				
			||||||
 | 
					    chunk_index[2] = chunk_index[1] + LedCount - ledOnCount;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
  debugSerial.print("Led min,max,count=");
 | 
					  debugSerial.print("LedStrip=>");
 | 
				
			||||||
  debugSerial.print(ledOnMin);
 | 
					  debugSerial.print(chunk_index[0]);
 | 
				
			||||||
  debugSerial.print(",");
 | 
					  debugSerial.print("<");
 | 
				
			||||||
  debugSerial.print(ledOnMax);
 | 
					  debugSerial.print(isChunkOn ? "ON" : "OFF");
 | 
				
			||||||
  debugSerial.print(",");
 | 
					  debugSerial.print(">");
 | 
				
			||||||
  debugSerial.println(LedOnCount);
 | 
					  debugSerial.print(chunk_index[1]);
 | 
				
			||||||
 | 
					  debugSerial.print("<");
 | 
				
			||||||
 | 
					  debugSerial.print(isChunkOn ? "OFF" : "ON");
 | 
				
			||||||
 | 
					  debugSerial.print(">");
 | 
				
			||||||
 | 
					  debugSerial.print(chunk_index[2]);
 | 
				
			||||||
 | 
					  debugSerial.print("<");
 | 
				
			||||||
 | 
					  debugSerial.print(isChunkOn ? "ON" : "OFF");
 | 
				
			||||||
 | 
					  debugSerial.print(">");
 | 
				
			||||||
 | 
					  debugSerial.print(chunk_index[3]);
 | 
				
			||||||
 | 
					  debugSerial.print("<");
 | 
				
			||||||
 | 
					  debugSerial.print(isChunkOn ? "OFF" : "ON");
 | 
				
			||||||
 | 
					  debugSerial.println(">");
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (size_t i = ledRingColorState.ledOnMin; i < ledRingColorState.ledOnMin + LedOnCount; ++i) {
 | 
					  for (size_t i = 0; i < 3; ++i) {
 | 
				
			||||||
    unsigned int ledId = i;
 | 
					    unsigned int firstLedOnChunk = chunk_index[i];
 | 
				
			||||||
    if (ledId >= LedCount) {
 | 
					    unsigned int lastLedOnChunk = chunk_index[i + 1];
 | 
				
			||||||
      ledId -= LedCount;
 | 
					    uint32_t color;
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    setPixelColor(ledId, ColorHSV(ledRingColorState.hue, ledRingColorState.saturation, ledRingColorState.brightness));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  show();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LedStrip::next_preset(void) {
 | 
					    if (isChunkOn) {
 | 
				
			||||||
  ++presetState.index;
 | 
					      color = ColorHSV(this->hue, this->saturation, this->brightness);
 | 
				
			||||||
  if (presetState.index >= PresetMax) {
 | 
					 | 
				
			||||||
    presetState.index = 0;
 | 
					 | 
				
			||||||
    ++presetState.level;
 | 
					 | 
				
			||||||
    if (presetState.level >= PresetLevelMax) {
 | 
					 | 
				
			||||||
      presetState.level = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void LedStrip::previous_preset(void) {
 | 
					 | 
				
			||||||
  --presetState.index;
 | 
					 | 
				
			||||||
  if (presetState.index == UINT8_MAX) {
 | 
					 | 
				
			||||||
    presetState.index = PresetMax - 1;
 | 
					 | 
				
			||||||
    --presetState.level;
 | 
					 | 
				
			||||||
    if (presetState.level == UINT8_MAX) {
 | 
					 | 
				
			||||||
      presetState.level = PresetLevelMax - 1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void LedStrip::display_led_ring(bool is_preset_enabled) {
 | 
					 | 
				
			||||||
  LedRingColorState_t colorState;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (is_preset_enabled) {
 | 
					 | 
				
			||||||
#if defined(__BUILD_DEBUG__) && false
 | 
					 | 
				
			||||||
    debugSerial.print("Preset index,level=");
 | 
					 | 
				
			||||||
    debugSerial.print(presetState.index);
 | 
					 | 
				
			||||||
    debugSerial.print(",");
 | 
					 | 
				
			||||||
    debugSerial.print(presetState.level);
 | 
					 | 
				
			||||||
    debugSerial.println();
 | 
					 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					 | 
				
			||||||
    colorState = {.ledOnMin = this->ledRingColorState.ledOnMin,
 | 
					 | 
				
			||||||
                  .ledOnMax = this->ledRingColorState.ledOnMax,
 | 
					 | 
				
			||||||
                  .hue = PresetHue[presetState.index],
 | 
					 | 
				
			||||||
                  .saturation = (presetState.index == (PresetMax - 1U)) ? 0U : UINT8_MAX,
 | 
					 | 
				
			||||||
                  .brightness = PresetBrightness[presetState.level]};
 | 
					 | 
				
			||||||
    refresh_led_ring(&colorState);
 | 
					 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
    refresh_led_ring();
 | 
					      color = 0;
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LedStrip::refresh_led_ring(LedRingColorState_t const *ledRingColorState) {
 | 
					    for (size_t j = firstLedOnChunk; j < lastLedOnChunk; ++j) {
 | 
				
			||||||
  if (ledRingColorState == nullptr) {
 | 
					      this->setPixelColor(j, color);
 | 
				
			||||||
    ledRingColorState = &this->ledRingColorState
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  uint16_t const &ledOnMin = ledRingColorState.ledOnMin;
 | 
					 | 
				
			||||||
  uint16_t const &ledOnMax = ledRingColorState.ledOnMax;
 | 
					 | 
				
			||||||
  uint16_t LedOnCount = 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					    isChunkOn = !isChunkOn; 
 | 
				
			||||||
  debugSerial.print("Color hue,sat,bri=");
 | 
					  }
 | 
				
			||||||
  debugSerial.print(ledRingColorState.hue);
 | 
					 | 
				
			||||||
  debugSerial.print(",");
 | 
					 | 
				
			||||||
  debugSerial.print(ledRingColorState.saturation);
 | 
					 | 
				
			||||||
  debugSerial.print(",");
 | 
					 | 
				
			||||||
  debugSerial.println(ledRingColorState.brightness);
 | 
					 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  /* reset ring */
 | 
					  this->show();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void LedStrip::display_mode(unsigned int mode_index) {
 | 
				
			||||||
 | 
					  for (size_t i = 0; i < 3; ++i) {
 | 
				
			||||||
    this->fill(0);
 | 
					    this->fill(0);
 | 
				
			||||||
 | 
					    this->show();
 | 
				
			||||||
  /* compute number of led on */
 | 
					    delay(150);
 | 
				
			||||||
  if (ledOnMin <= ledOnMax) {
 | 
					    for (size_t i = 0; i < mode_index; ++i) {
 | 
				
			||||||
    LedOnCount = ledOnMax - ledOnMin;
 | 
					      this->setPixelColor(i, ColorHSV(0, 255, 16));
 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    LedOnCount = ledCount - (ledOnMax - ledOnMax);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    this->show();
 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					    delay(150);
 | 
				
			||||||
  debugSerial.print("Led min,max,count=");
 | 
					 | 
				
			||||||
  debugSerial.print(ledOnMin);
 | 
					 | 
				
			||||||
  debugSerial.print(",");
 | 
					 | 
				
			||||||
  debugSerial.print(ledOnMax);
 | 
					 | 
				
			||||||
  debugSerial.print(",");
 | 
					 | 
				
			||||||
  debugSerial.println(LedOnCount);
 | 
					 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (size_t i = ledRingColorState.ledOnMin; i < ledRingColorState.ledOnMin + LedOnCount; ++i) {
 | 
					 | 
				
			||||||
    unsigned int ledId = i;
 | 
					 | 
				
			||||||
    if (ledId >= LedCount) {
 | 
					 | 
				
			||||||
      ledId -= LedCount;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
    ledRing.setPixelColor(ledId, Adafruit_NeoPixel::ColorHSV(ledRingColorState.hue, ledRingColorState.saturation,
 | 
					  this->refresh();
 | 
				
			||||||
                                                             ledRingColorState.brightness));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
  ledRing.show();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// void display_mode(Mode_e mode) {
 | 
					 | 
				
			||||||
//   if (currentMode != Mode_e::ControlOff) {
 | 
					 | 
				
			||||||
//     for (size_t i = 0; i < 3; ++i) {
 | 
					 | 
				
			||||||
//       fill(0);
 | 
					 | 
				
			||||||
//       show();
 | 
					 | 
				
			||||||
//       delay(300);
 | 
					 | 
				
			||||||
//       for (Mode_e i = Mode_e::Init; i < currentMode; ++i) {
 | 
					 | 
				
			||||||
//         setPixelColor(int(i), Adafruit_NeoPixel::ColorHSV(0, 255, 16));
 | 
					 | 
				
			||||||
//       }
 | 
					 | 
				
			||||||
//       show();
 | 
					 | 
				
			||||||
//       delay(300);
 | 
					 | 
				
			||||||
//     }
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
// }
 | 
					 | 
				
			||||||
@@ -9,32 +9,8 @@
 | 
				
			|||||||
#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
 | 
					#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "pin_map.hpp"
 | 
					#include "pin_map.hpp"
 | 
				
			||||||
 | 
					#include "global.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Leds */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Led ring color and led count state */
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
  uint16_t ledOnMin;
 | 
					 | 
				
			||||||
  uint16_t ledOnMax;
 | 
					 | 
				
			||||||
  uint16_t hue;
 | 
					 | 
				
			||||||
  uint8_t saturation;
 | 
					 | 
				
			||||||
  uint8_t brightness;
 | 
					 | 
				
			||||||
} LedRingColorState_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint8_t const PresetMax{8};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// https://hslpicker.com/          = {0, 40, 50, 110, 240, 280, 310, 360 for white}
 | 
					 | 
				
			||||||
uint16_t const PresetHue[PresetMax] = {0, 7282, 9102, 20025, 43691, 50972, 56434, 65535};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint8_t const PresetLevelMax{3};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint8_t const PresetBrightness[PresetLevelMax] = {16, 64, 127};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Preset state */
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
  uint8_t index;
 | 
					 | 
				
			||||||
  uint8_t level;
 | 
					 | 
				
			||||||
} PresetState_t;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
 | 
					#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
 | 
				
			||||||
class LedStrip : tinyNeoPixel {
 | 
					class LedStrip : tinyNeoPixel {
 | 
				
			||||||
@@ -44,32 +20,39 @@ class LedStrip : Adafruit_NeoPixel {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
 | 
					#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
 | 
				
			||||||
  LedStrip(void) : tinyNeoPixel{LedCount, LedPin, NEO_GRB + NEO_KHZ800, pixels} {}
 | 
					  LedStrip(void)
 | 
				
			||||||
 | 
					      : tinyNeoPixel{LedCount, LedPin, NEO_GRB + NEO_KHZ800, pixels}, firstLedOn{0},
 | 
				
			||||||
 | 
					        ledOnCount{LedCount}, hue{2048}, saturation{207}, brightness{239} {}
 | 
				
			||||||
  void fill(uint32_t c = 0, uint16_t first = 0, uint16_t count = 0);
 | 
					  void fill(uint32_t c = 0, uint16_t first = 0, uint16_t count = 0);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
  LedStrip(void) : Adafruit_NeoPixel{LedCount, LedPin, NEO_GRB + NEO_KHZ800} {}
 | 
					  LedStrip(void)
 | 
				
			||||||
 | 
					      : Adafruit_NeoPixel{LedCount, LedPin, NEO_GRB + NEO_KHZ800}, firstLedOn{0}, ledOnCount{LedCount},
 | 
				
			||||||
 | 
					        hue{2048}, saturation{207}, brightness{239} {}
 | 
				
			||||||
#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
 | 
					#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
 | 
				
			||||||
  virtual ~LedStrip() {}
 | 
					  virtual ~LedStrip() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void setup();
 | 
					  void setup(bool is_diag_mode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void display_mode(unsigned int mode_index);
 | 
				
			||||||
  void refresh();
 | 
					  void refresh();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void next_preset();
 | 
					  void shiftHue(int shift);
 | 
				
			||||||
  void previous_preset();
 | 
					  void shiftSaturation(int shift);
 | 
				
			||||||
  void display_led_ring(bool is_preset_enabled);
 | 
					  void shiftBrightness(int shift);
 | 
				
			||||||
 | 
					  void shiftFirstLedOn(int shift);
 | 
				
			||||||
 | 
					  void shiftLedOnLenght(int shift);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  uint16_t static const LedCount{24};
 | 
					  uint16_t static const LedCount{LED_STRIP_LEGNTH};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*  IO Objects */
 | 
					 | 
				
			||||||
#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
 | 
					#if defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41)
 | 
				
			||||||
  byte pixels[LedCount * 3];
 | 
					  byte pixels[LedCount * 3];
 | 
				
			||||||
#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
 | 
					#endif /* defined(ARDUINO_AVR_ATTINYX5) || defined(ARDUINO_AVR_ATTINYX41) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  LedRingColorState_t ledRingColorState = {
 | 
					  unsigned int firstLedOn, ledOnCount;
 | 
				
			||||||
      .ledOnMin = 0, .ledOnMax = LedCount / 2, .hue = 0, .saturation = 255, .brightness = 16};
 | 
					  uint16_t hue;
 | 
				
			||||||
  PresetState_t presetState = {.index = 0, .level = 0};
 | 
					  uint8_t saturation;
 | 
				
			||||||
  void refresh_led_ring(LedRingColorState_t const *ledRingColorState = nullptr);
 | 
					  uint8_t brightness;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __LED_STRIP_HPP__ */
 | 
					#endif /* __LED_STRIP_HPP__ */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										315
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										315
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -1,4 +1,8 @@
 | 
				
			|||||||
#include <Arduino.h>
 | 
					#include <Arduino.h>
 | 
				
			||||||
 | 
					#if defined(__BUILD_DEBUG__) && !defined(ARDUINO_AVR_UNO)
 | 
				
			||||||
 | 
					/* Using interrupts with serial seems to cause instability */
 | 
				
			||||||
 | 
					#define ENCODER_DO_NOT_USE_INTERRUPTS
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#include <Encoder.h>
 | 
					#include <Encoder.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "global.hpp"
 | 
					#include "global.hpp"
 | 
				
			||||||
@@ -12,14 +16,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* State machine */
 | 
					/* State machine */
 | 
				
			||||||
#define FOREACH_MODE(MODE)                                                                                             \
 | 
					#define FOREACH_MODE(MODE)                                                                                             \
 | 
				
			||||||
  MODE(Init)                                                                                                           \
 | 
					  MODE(FirstLedOn)                                                                                                     \
 | 
				
			||||||
  MODE(LightOnMin)                                                                                                     \
 | 
					  MODE(LedOnLength)                                                                                                    \
 | 
				
			||||||
  MODE(LightOnMax)                                                                                                     \
 | 
					 | 
				
			||||||
  MODE(Preset)                                                                                                         \
 | 
					 | 
				
			||||||
  MODE(SetColor)                                                                                                       \
 | 
					  MODE(SetColor)                                                                                                       \
 | 
				
			||||||
  MODE(SetSaturation)                                                                                                  \
 | 
					  MODE(SetSaturation)                                                                                                  \
 | 
				
			||||||
  MODE(SetBrightness)                                                                                                  \
 | 
					  MODE(SetBrightness)                                                                                                  \
 | 
				
			||||||
  MODE(ControlOff)
 | 
					  MODE(ControlOff)                                                                                                     \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GENERATE_MODE_ENUM(ENUM) ENUM,
 | 
					#define GENERATE_MODE_ENUM(ENUM) ENUM,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -29,7 +32,7 @@ enum class Mode_e { FOREACH_MODE(GENERATE_MODE_ENUM) };
 | 
				
			|||||||
/* Cyclic increment operator for Mode_e */
 | 
					/* Cyclic increment operator for Mode_e */
 | 
				
			||||||
Mode_e &operator++(Mode_e &mode) {
 | 
					Mode_e &operator++(Mode_e &mode) {
 | 
				
			||||||
  if (mode == Mode_e::ControlOff) {
 | 
					  if (mode == Mode_e::ControlOff) {
 | 
				
			||||||
    return mode = Mode_e::Init;
 | 
					    return mode = Mode_e::FirstLedOn;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return mode = static_cast<Mode_e>(static_cast<int>(mode) + 1);
 | 
					  return mode = static_cast<Mode_e>(static_cast<int>(mode) + 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -41,7 +44,7 @@ char static const *mode_str[] = {FOREACH_MODE(GENERATE_MODE_STRING)};
 | 
				
			|||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Led ring system state */
 | 
					/* Led ring system state */
 | 
				
			||||||
Mode_e currentMode{Mode_e::Init};
 | 
					Mode_e currentMode{Mode_e::ControlOff};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Global variables */
 | 
					/* Global variables */
 | 
				
			||||||
/*--------------------------------------------------------------------------------------------------------------------*/
 | 
					/*--------------------------------------------------------------------------------------------------------------------*/
 | 
				
			||||||
@@ -49,12 +52,16 @@ Mode_e currentMode{Mode_e::Init};
 | 
				
			|||||||
/*  IO Objects */
 | 
					/*  IO Objects */
 | 
				
			||||||
Encoder encoder{EncoderPinA, EncoderPinB};
 | 
					Encoder encoder{EncoderPinA, EncoderPinB};
 | 
				
			||||||
#if defined(ARDUINO_AVR_ATTINYX5)
 | 
					#if defined(ARDUINO_AVR_ATTINYX5)
 | 
				
			||||||
AnalogButton button{AnalogButtonPin, AnalogButtonVRef};
 | 
					AnalogButton button{ButtonPin, AnalogButtonVRef};
 | 
				
			||||||
#elif defined(ARDUINO_AVR_ATTINYX41)
 | 
					#elif defined(ARDUINO_AVR_ATTINYX41)
 | 
				
			||||||
Button button{ButtonPin};
 | 
					Button button{ButtonPin};
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
					#if defined(ANALOG_BUTTON)
 | 
				
			||||||
/* No vRef defined force to calibrate for test purpose */
 | 
					/* No vRef defined force to calibrate for test purpose */
 | 
				
			||||||
AnalogButton button{AnalogButtonPin};
 | 
					AnalogButton button{ButtonPin};
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					Button button{ButtonPin};
 | 
				
			||||||
 | 
					#endif /* defined(ANALOG_BUTTON) */
 | 
				
			||||||
#endif /* defined(ARDUINO_AVR_ATTINYX41) */
 | 
					#endif /* defined(ARDUINO_AVR_ATTINYX41) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LedStrip ledStrip{};
 | 
					LedStrip ledStrip{};
 | 
				
			||||||
@@ -65,7 +72,7 @@ LedStrip ledStrip{};
 | 
				
			|||||||
SoftwareSerial debugSerial{RxPin, TxPin};
 | 
					SoftwareSerial debugSerial{RxPin, TxPin};
 | 
				
			||||||
#elif defined(ARDUINO_AVR_ATTINYX41)
 | 
					#elif defined(ARDUINO_AVR_ATTINYX41)
 | 
				
			||||||
HardwareSerial &debugSerial = Serial1;
 | 
					HardwareSerial &debugSerial = Serial1;
 | 
				
			||||||
#elif
 | 
					#else
 | 
				
			||||||
HardwareSerial &debugSerial = Serial;
 | 
					HardwareSerial &debugSerial = Serial;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
@@ -77,23 +84,11 @@ HardwareSerial &debugSerial = Serial;
 | 
				
			|||||||
#define GENERATE_MODE_EXEC_DECLARTION(MODE) void MODE##_execute(int shift);
 | 
					#define GENERATE_MODE_EXEC_DECLARTION(MODE) void MODE##_execute(int shift);
 | 
				
			||||||
FOREACH_MODE(GENERATE_MODE_EXEC_DECLARTION)
 | 
					FOREACH_MODE(GENERATE_MODE_EXEC_DECLARTION)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Encoder */
 | 
					 | 
				
			||||||
void analog_button_calibration(void);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int get_encoder_shift(void);
 | 
					int get_encoder_shift(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// void display_mode(Mode_e mode);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// void display_led_ring(void);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// void refresh_led_ring(LedRingColorState_t const &ledRingColorState = ledRingState.ledRingColorState);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Function definitions */
 | 
					/* Function definitions */
 | 
				
			||||||
/*--------------------------------------------------------------------------------------------------------------------*/
 | 
					/*--------------------------------------------------------------------------------------------------------------------*/
 | 
				
			||||||
void setup() {
 | 
					void setup() {
 | 
				
			||||||
  ledStrip.setup();
 | 
					 | 
				
			||||||
  button.setup();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
  debugSerial.begin(9600);
 | 
					  debugSerial.begin(9600);
 | 
				
			||||||
#if defined(DEBUG_INIT)
 | 
					#if defined(DEBUG_INIT)
 | 
				
			||||||
@@ -103,6 +98,9 @@ void setup() {
 | 
				
			|||||||
  debugSerial.println("Init ... ");
 | 
					  debugSerial.println("Init ... ");
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  button.setup();
 | 
				
			||||||
 | 
					  ledStrip.setup(button.is_pressed());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  get_encoder_shift();
 | 
					  get_encoder_shift();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
@@ -111,12 +109,11 @@ void setup() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void loop() {
 | 
					void loop() {
 | 
				
			||||||
  bool hasModeChanged{false};
 | 
					 | 
				
			||||||
  int shift{get_encoder_shift()};
 | 
					  int shift{get_encoder_shift()};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (button.is_button_pressed()) {
 | 
					  if (button.is_pressed()) {
 | 
				
			||||||
    while (button.is_button_pressed()) {
 | 
					    while (button.is_pressed()) {
 | 
				
			||||||
      delay(150);
 | 
					      delay(10);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    ++currentMode;
 | 
					    ++currentMode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -124,10 +121,10 @@ void loop() {
 | 
				
			|||||||
    debugSerial.println(mode_str[static_cast<int>(currentMode)]);
 | 
					    debugSerial.println(mode_str[static_cast<int>(currentMode)]);
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // display_mode(currentMode);
 | 
					    if (currentMode != Mode_e::ControlOff) {
 | 
				
			||||||
    hasModeChanged = true;
 | 
					      ledStrip.display_mode(static_cast<unsigned int>(currentMode) + 1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  ledStrip.setup();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (shift != 0) {
 | 
					  if (shift != 0) {
 | 
				
			||||||
    switch (currentMode) {
 | 
					    switch (currentMode) {
 | 
				
			||||||
@@ -135,38 +132,34 @@ void loop() {
 | 
				
			|||||||
      ControlOff_execute(shift);
 | 
					      ControlOff_execute(shift);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case Mode_e::Preset:
 | 
					    case Mode_e::SetColor:
 | 
				
			||||||
      Preset_execute(shift);
 | 
					      SetColor_execute(shift);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //   case Mode_e::SetColor:
 | 
					    case Mode_e::SetBrightness:
 | 
				
			||||||
      //     SetColor_execute(shift);
 | 
					      SetBrightness_execute(shift);
 | 
				
			||||||
      //     break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //   case Mode_e::SetBrightness:
 | 
					    case Mode_e::SetSaturation:
 | 
				
			||||||
      //     SetBrightness_execute(shift);
 | 
					      SetSaturation_execute(shift);
 | 
				
			||||||
      //     break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //   case Mode_e::SetSaturation:
 | 
					    case Mode_e::FirstLedOn:
 | 
				
			||||||
      //     SetSaturation_execute(shift);
 | 
					      FirstLedOn_execute(shift);
 | 
				
			||||||
      //     break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //   case Mode_e::LightOnMin:
 | 
					    case Mode_e::LedOnLength:
 | 
				
			||||||
      //     LightOnMin_execute(shift);
 | 
					      LedOnLength_execute(shift);
 | 
				
			||||||
      //     break;
 | 
					      break;
 | 
				
			||||||
 | 
					 | 
				
			||||||
      //   case Mode_e::LightOnMax:
 | 
					 | 
				
			||||||
      //     LightOnMax_execute(shift);
 | 
					 | 
				
			||||||
      //     break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // if (currentMode != Mode_e::ControlOff && (shift != 0 || hasModeChanged)) {
 | 
					  if (currentMode != Mode_e::ControlOff && shift != 0) {
 | 
				
			||||||
  //   display_led_ring();
 | 
					    ledStrip.refresh();
 | 
				
			||||||
  // }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Private function definitions */
 | 
					/* Private function definitions */
 | 
				
			||||||
@@ -176,135 +169,25 @@ void loop() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void ControlOff_execute(int shift) {}
 | 
					void ControlOff_execute(int shift) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Preset_execute(int shift) {
 | 
					void SetColor_execute(int shift) {
 | 
				
			||||||
  if (shift > 0) {
 | 
					  ledStrip.shiftHue(shift);
 | 
				
			||||||
    ledStrip.next_preset();
 | 
					} /* SetColor_execute */
 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    ledStrip.previous_preset();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
} /* Preset_execute */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// void SetColor_execute(int shift) {
 | 
					void SetBrightness_execute(int shift) {
 | 
				
			||||||
//   uint16_t &hue = ledRingState.ledRingColorState.hue;
 | 
					  ledStrip.shiftBrightness(shift);
 | 
				
			||||||
 | 
					} /* SetBrightness_execute */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//   hue += (shift << 8);
 | 
					void SetSaturation_execute(int shift) {
 | 
				
			||||||
 | 
					  ledStrip.shiftSaturation(shift);
 | 
				
			||||||
 | 
					} /* SetSaturation_execute */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// #if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
					void FirstLedOn_execute(int shift) {
 | 
				
			||||||
//   if (shift != 0) {
 | 
					  ledStrip.shiftFirstLedOn(shift);
 | 
				
			||||||
//     debugSerial.print(__func__);
 | 
					} /* FirstLedOn_execute */
 | 
				
			||||||
//     debugSerial.print(" : shift=");
 | 
					 | 
				
			||||||
//     debugSerial.print(shift, DEC);
 | 
					 | 
				
			||||||
//     debugSerial.print(", hue=");
 | 
					 | 
				
			||||||
//     debugSerial.println(hue, DEC);
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
// #endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
					 | 
				
			||||||
// } /* SetColor_execute */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// void SetBrightness_execute(int shift) {
 | 
					void LedOnLength_execute(int shift) {
 | 
				
			||||||
//   uint8_t &brightness = ledRingState.ledRingColorState.brightness;
 | 
					  ledStrip.shiftLedOnLenght(shift);
 | 
				
			||||||
 | 
					} /* LedOnLength_execute */
 | 
				
			||||||
//   brightness += (shift << 2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// #if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
					 | 
				
			||||||
//   if (shift != 0) {
 | 
					 | 
				
			||||||
//     debugSerial.print(__func__);
 | 
					 | 
				
			||||||
//     debugSerial.print(" : shift=");
 | 
					 | 
				
			||||||
//     debugSerial.print(shift, DEC);
 | 
					 | 
				
			||||||
//     debugSerial.print(", brightness=");
 | 
					 | 
				
			||||||
//     debugSerial.println(brightness, DEC);
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
// #endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
					 | 
				
			||||||
// } /* SetBrightness_execute */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// void SetSaturation_execute(int shift) {
 | 
					 | 
				
			||||||
//   uint8_t &saturation = ledRingState.ledRingColorState.saturation;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//   saturation += (shift << 2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// #if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
					 | 
				
			||||||
//   if (shift != 0) {
 | 
					 | 
				
			||||||
//     debugSerial.print(__func__);
 | 
					 | 
				
			||||||
//     debugSerial.print(" : shift=");
 | 
					 | 
				
			||||||
//     debugSerial.print(shift, DEC);
 | 
					 | 
				
			||||||
//     debugSerial.print(", saturation=");
 | 
					 | 
				
			||||||
//     debugSerial.println(saturation, DEC);
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
// #endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
					 | 
				
			||||||
// } /* SetSaturation_execute */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// void LightOnMin_execute(int shift) {
 | 
					 | 
				
			||||||
//   uint16_t &ledOnMin = ledRingState.ledRingColorState.ledOnMin;
 | 
					 | 
				
			||||||
//   uint16_t &ledOnMax = ledRingState.ledRingColorState.ledOnMax;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//   if (shift > 0) {
 | 
					 | 
				
			||||||
//     if (ledOnMin == ledOnMax) {
 | 
					 | 
				
			||||||
//       currentMode = Mode_e::LightOnMax;
 | 
					 | 
				
			||||||
//       ++ledOnMax;
 | 
					 | 
				
			||||||
//     } else {
 | 
					 | 
				
			||||||
//       ++ledOnMin;
 | 
					 | 
				
			||||||
//       if (ledOnMin == LedCount) {
 | 
					 | 
				
			||||||
//         ledOnMin = 0;
 | 
					 | 
				
			||||||
//       }
 | 
					 | 
				
			||||||
//     }
 | 
					 | 
				
			||||||
//   } else {
 | 
					 | 
				
			||||||
//     if (ledOnMin == ledOnMax) {
 | 
					 | 
				
			||||||
//       currentMode = Mode_e::LightOnMax;
 | 
					 | 
				
			||||||
//       --ledOnMax;
 | 
					 | 
				
			||||||
//     } else {
 | 
					 | 
				
			||||||
//       --ledOnMin;
 | 
					 | 
				
			||||||
//       if (ledOnMin == UINT16_MAX) {
 | 
					 | 
				
			||||||
//         ledOnMin = LedCount - 1;
 | 
					 | 
				
			||||||
//       }
 | 
					 | 
				
			||||||
//     }
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// #if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
					 | 
				
			||||||
//   if (shift != 0) {
 | 
					 | 
				
			||||||
//     debugSerial.print(__func__);
 | 
					 | 
				
			||||||
//     debugSerial.print(" : shift=");
 | 
					 | 
				
			||||||
//     debugSerial.print(shift, DEC);
 | 
					 | 
				
			||||||
//     debugSerial.print(", ledOnMin=");
 | 
					 | 
				
			||||||
//     debugSerial.println(ledOnMin, DEC);
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
// #endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
					 | 
				
			||||||
// } /* LightOnMin_execute */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// void LightOnMax_execute(int shift) {
 | 
					 | 
				
			||||||
//   uint16_t &ledOnMin = ledRingState.ledRingColorState.ledOnMin;
 | 
					 | 
				
			||||||
//   uint16_t &ledOnMax = ledRingState.ledRingColorState.ledOnMax;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//   if (shift > 0) {
 | 
					 | 
				
			||||||
//     if (ledOnMax == ledOnMin) {
 | 
					 | 
				
			||||||
//       currentMode = Mode_e::LightOnMin;
 | 
					 | 
				
			||||||
//       ++ledOnMin;
 | 
					 | 
				
			||||||
//     } else {
 | 
					 | 
				
			||||||
//       ++ledOnMax;
 | 
					 | 
				
			||||||
//       if (ledOnMax == LedCount) {
 | 
					 | 
				
			||||||
//         ledOnMax = 0;
 | 
					 | 
				
			||||||
//       }
 | 
					 | 
				
			||||||
//     }
 | 
					 | 
				
			||||||
//   } else {
 | 
					 | 
				
			||||||
//     if (ledOnMax == ledOnMin) {
 | 
					 | 
				
			||||||
//       currentMode = Mode_e::LightOnMin;
 | 
					 | 
				
			||||||
//       --ledOnMin;
 | 
					 | 
				
			||||||
//     } else {
 | 
					 | 
				
			||||||
//       --ledOnMax;
 | 
					 | 
				
			||||||
//       if (ledOnMax == UINT16_MAX) {
 | 
					 | 
				
			||||||
//         ledOnMax = LedCount - 1;
 | 
					 | 
				
			||||||
//       }
 | 
					 | 
				
			||||||
//     }
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// #if defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)
 | 
					 | 
				
			||||||
//   if (shift != 0) {
 | 
					 | 
				
			||||||
//     debugSerial.print(__func__);
 | 
					 | 
				
			||||||
//     debugSerial.print(" : shift=");
 | 
					 | 
				
			||||||
//     debugSerial.print(shift, DEC);
 | 
					 | 
				
			||||||
//     debugSerial.print(", ledOnMax=");
 | 
					 | 
				
			||||||
//     debugSerial.println(ledOnMax, DEC);
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
// #endif /*defined(__BUILD_DEBUG__) && defined(ARDUINO_AVR_UNO)*/
 | 
					 | 
				
			||||||
// } /* LightOnMax_execute */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Others functions */
 | 
					/* Others functions */
 | 
				
			||||||
int get_encoder_shift(void) {
 | 
					int get_encoder_shift(void) {
 | 
				
			||||||
@@ -325,85 +208,3 @@ int get_encoder_shift(void) {
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// void display_mode(Mode_e mode) {
 | 
					 | 
				
			||||||
//   if (currentMode != Mode_e::ControlOff) {
 | 
					 | 
				
			||||||
//     for (size_t i = 0; i < 3; ++i) {
 | 
					 | 
				
			||||||
//       ledRing.fill(0);
 | 
					 | 
				
			||||||
//       ledRing.show();
 | 
					 | 
				
			||||||
//       delay(300);
 | 
					 | 
				
			||||||
//       for (Mode_e i = Mode_e::Init; i < currentMode; ++i) {
 | 
					 | 
				
			||||||
//         ledRing.setPixelColor(int(i), Adafruit_NeoPixel::ColorHSV(0, 255, 16));
 | 
					 | 
				
			||||||
//       }
 | 
					 | 
				
			||||||
//       ledRing.show();
 | 
					 | 
				
			||||||
//       delay(300);
 | 
					 | 
				
			||||||
//     }
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
// }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// void display_led_ring(void) {
 | 
					 | 
				
			||||||
//   PresetState_t &preset = ledRingState.presetState;
 | 
					 | 
				
			||||||
//   LedRingColorState_t ledRingColorState;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//   if (currentMode == Mode_e::Preset) {
 | 
					 | 
				
			||||||
// #if defined(__BUILD_DEBUG__) && false
 | 
					 | 
				
			||||||
//     debugSerial.print("Preset index,level=");
 | 
					 | 
				
			||||||
//     debugSerial.print(preset.index);
 | 
					 | 
				
			||||||
//     debugSerial.print(",");
 | 
					 | 
				
			||||||
//     debugSerial.print(preset.level);
 | 
					 | 
				
			||||||
//     debugSerial.println();
 | 
					 | 
				
			||||||
// #endif /* defined(__BUILD_DEBUG__) */
 | 
					 | 
				
			||||||
//     ledRingColorState = {.ledOnMin = ledRingState.ledRingColorState.ledOnMin,
 | 
					 | 
				
			||||||
//                          .ledOnMax = ledRingState.ledRingColorState.ledOnMax,
 | 
					 | 
				
			||||||
//                          .hue = PresetHue[preset.index],
 | 
					 | 
				
			||||||
//                          .saturation = (preset.index == (PresetMax - 1)) ? 0 : UINT8_MAX,
 | 
					 | 
				
			||||||
//                          .brightness = PresetBrightness[preset.level]};
 | 
					 | 
				
			||||||
//     refresh_led_ring(ledRingColorState);
 | 
					 | 
				
			||||||
//   } else {
 | 
					 | 
				
			||||||
//     refresh_led_ring();
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
// }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// void refresh_led_ring(LedRingColorState_t const &ledRingColorState) {
 | 
					 | 
				
			||||||
//   uint16_t const &ledOnMin = ledRingColorState.ledOnMin;
 | 
					 | 
				
			||||||
//   uint16_t const &ledOnMax = ledRingColorState.ledOnMax;
 | 
					 | 
				
			||||||
//   uint16_t LedOnCount = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// #if defined(__BUILD_DEBUG__)
 | 
					 | 
				
			||||||
//   debugSerial.print("Color hue,sat,bri=");
 | 
					 | 
				
			||||||
//   debugSerial.print(ledRingColorState.hue);
 | 
					 | 
				
			||||||
//   debugSerial.print(",");
 | 
					 | 
				
			||||||
//   debugSerial.print(ledRingColorState.saturation);
 | 
					 | 
				
			||||||
//   debugSerial.print(",");
 | 
					 | 
				
			||||||
//   debugSerial.println(ledRingColorState.brightness);
 | 
					 | 
				
			||||||
// #endif /* defined(__BUILD_DEBUG__) */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//   /* reset ring */
 | 
					 | 
				
			||||||
//   ledRing.fill(0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//   /* compute number of led on */
 | 
					 | 
				
			||||||
//   if (ledOnMin <= ledOnMax) {
 | 
					 | 
				
			||||||
//     LedOnCount = ledOnMax - ledOnMin;
 | 
					 | 
				
			||||||
//   } else {
 | 
					 | 
				
			||||||
//     LedOnCount = LedCount - (ledOnMax - ledOnMax);
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// #if defined(__BUILD_DEBUG__)
 | 
					 | 
				
			||||||
//   debugSerial.print("Led min,max,count=");
 | 
					 | 
				
			||||||
//   debugSerial.print(ledOnMin);
 | 
					 | 
				
			||||||
//   debugSerial.print(",");
 | 
					 | 
				
			||||||
//   debugSerial.print(ledOnMax);
 | 
					 | 
				
			||||||
//   debugSerial.print(",");
 | 
					 | 
				
			||||||
//   debugSerial.println(LedOnCount);
 | 
					 | 
				
			||||||
// #endif /* defined(__BUILD_DEBUG__) */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//   for (size_t i = ledRingColorState.ledOnMin; i < ledRingColorState.ledOnMin + LedOnCount; ++i) {
 | 
					 | 
				
			||||||
//     unsigned int ledId = i;
 | 
					 | 
				
			||||||
//     if (ledId >= LedCount) {
 | 
					 | 
				
			||||||
//       ledId -= LedCount;
 | 
					 | 
				
			||||||
//     }
 | 
					 | 
				
			||||||
//     ledRing.setPixelColor(ledId, Adafruit_NeoPixel::ColorHSV(ledRingColorState.hue, ledRingColorState.saturation,
 | 
					 | 
				
			||||||
//                                                              ledRingColorState.brightness));
 | 
					 | 
				
			||||||
//   }
 | 
					 | 
				
			||||||
//   ledRing.show();
 | 
					 | 
				
			||||||
// }
 | 
					 | 
				
			||||||
@@ -3,47 +3,51 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#if defined(ARDUINO_AVR_ATTINYX5)
 | 
					#if defined(ARDUINO_AVR_ATTINYX5)
 | 
				
			||||||
/* LedStrip output pin */
 | 
					/* LedStrip output pin */
 | 
				
			||||||
uint8_t const LedPin{PB0};
 | 
					uint8_t const LedPin{PIN_PB0};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Button analog input pin */
 | 
					/* Button analog input pin */
 | 
				
			||||||
/* Note: we use PB5 as button input which is also the reset pin, to avoid reseting we read an analogic value with
 | 
					/* Note: we use PB5 as button input which is also the reset pin, to avoid reseting we read an analogic value with
 | 
				
			||||||
 * lower voltage than the triger value of reset */
 | 
					 * lower voltage than the triger value of reset */
 | 
				
			||||||
int const AnalogButtonVRef{970};
 | 
					int const AnalogButtonVRef{970};
 | 
				
			||||||
uint8_t const AnalogButtonPin{0};
 | 
					uint8_t const ButtonPin{PINA0};
 | 
				
			||||||
/* Rotary encoder input pins */
 | 
					/* Rotary encoder input pins */
 | 
				
			||||||
uint8_t const EncoderPinA{PB3};
 | 
					/* TODO: change to PB2 for using int0 */
 | 
				
			||||||
uint8_t const EncoderPinB{PB4};
 | 
					uint8_t const EncoderPinA{PIN_PB3};
 | 
				
			||||||
 | 
					uint8_t const EncoderPinB{PIN_PB4};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Uart for serial debug pins */
 | 
					/* Uart for serial debug pins */
 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
uint8_t const TxPin{PB1};
 | 
					uint8_t const TxPin{PIN_PB1};
 | 
				
			||||||
uint8_t const RxPin{PB2};
 | 
					uint8_t const RxPin{PIN_PB2};
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
#elif defined(ARDUINO_AVR_ATTINYX41)
 | 
					#elif defined(ARDUINO_AVR_ATTINYX41)
 | 
				
			||||||
/* LedStrip output pin */
 | 
					/* LedStrip output pin */
 | 
				
			||||||
uint8_t const LedPin{PA1};
 | 
					uint8_t const LedPin{PIN_PA1};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Button input pin (internally pulled up) */
 | 
					/* Button input pin (internally pulled up) */
 | 
				
			||||||
uint8_t const ButtonPin{ADC11D};
 | 
					uint8_t const ButtonPin{PIN_PA0};
 | 
				
			||||||
/* Rotary encoder input pins */
 | 
					/* Rotary encoder input pins */
 | 
				
			||||||
uint8_t const EncoderPinA{PA2};
 | 
					/* PB1 is interrupt pin (int0)*/
 | 
				
			||||||
uint8_t const EncoderPinB{PA3};
 | 
					uint8_t const EncoderPinA{PIN_PB1};
 | 
				
			||||||
 | 
					uint8_t const EncoderPinB{PIN_PB0};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Uart for serial debug pins */
 | 
					/* Uart for serial debug pins */
 | 
				
			||||||
#if defined(__BUILD_DEBUG__)
 | 
					#if defined(__BUILD_DEBUG__)
 | 
				
			||||||
uint8_t const TxPin{PA5};
 | 
					uint8_t const TxPin{PIN_PA5};
 | 
				
			||||||
uint8_t const RxPin{PA4};
 | 
					uint8_t const RxPin{PIN_PA4};
 | 
				
			||||||
#endif /* defined(__BUILD_DEBUG__) */
 | 
					#endif /* defined(__BUILD_DEBUG__) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#elif defined(ARDUINO_AVR_UNO)
 | 
					#elif defined(ARDUINO_AVR_UNO)
 | 
				
			||||||
/* LedStrip output pin */
 | 
					/* LedStrip output pin */
 | 
				
			||||||
uint8_t const LedPin{6};
 | 
					uint8_t const LedPin{11};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Button analog input pin */
 | 
					/* Button analog input pin */
 | 
				
			||||||
uint8_t const AnalogButtonPin{A0};
 | 
					uint8_t const ButtonPin{A0};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Rotary encoder input pins */
 | 
					/* Rotary encoder input pins */
 | 
				
			||||||
uint8_t const EncoderPinA{8};
 | 
					/* INT0 and INT1 */
 | 
				
			||||||
uint8_t const EncoderPinB{9};
 | 
					uint8_t const EncoderPinA{2};
 | 
				
			||||||
 | 
					uint8_t const EncoderPinB{3};
 | 
				
			||||||
#endif /* Hardware selection */
 | 
					#endif /* Hardware selection */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __PIN_MAP_HPP__ */
 | 
					#endif /* __PIN_MAP_HPP__ */
 | 
				
			||||||
		Reference in New Issue
	
	Block a user