<commit_before>/* BISMILLAH																																											*/
///		<NAME>
///		<NAME>
																																														/*
 * made from scratch 
 * 30 OKTOBER 2011
 * Makin
 * 
 * ATMEGA 32:
 * 	EEPROM 1024 Bytes
 * 	SRAM	  2048 Bytes
 * 
 * ADC sensor dpn 34567 ~67 adc, 345 sel
 */

//~ #define F_CPU 12000000
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>
#include <avr/pgmspace.h>
#include "lcd_lib.h"
#include <avr/eeprom.h>
#include "makin.h"

#define elif else if


///~ #define EepromWrite(_BLOCK,_VALUE)	eeprom_write_byte((uint8_t*)(_BLOCK),_VALUE) 
///Use update instead of write
#define EepromWrite(_BLOCK,_VALUE)	eeprom_update_byte((uint8_t*)(_BLOCK),_VALUE)
#define EepromRead(_BLOCK)	eeprom_read_byte((uint8_t*)(_BLOCK))


#define A_CUSTOM_COUNT 1


///Sensor case
#define ADDRESS_BLOCK_CASE_N		2
#define CASE_SIZE					40
#define ADDRESS_BLOCK_CASE_H		ADDRESS_BLOCK_CASE_N+1
#define ADDRESS_BLOCK_CASE_L		ADDRESS_BLOCK_CASE_H+CASE_SIZE+1
#define ADDRESS_BLOCK_CASE_V		ADDRESS_BLOCK_CASE_L+CASE_SIZE+1

#define ADDRESS_BLOCK_MAP_WAYPOINTS_NUM		ADDRESS_BLOCK_CASE_V+CASE_SIZE+1
#define MAP_MAXIMUM_WAYPOINT				200
#define ADDRESS_BLOCK_MAP_ACT_LOW			ADDRESS_BLOCK_MAP_WAYPOINTS_NUM+1
#define ADDRESS_BLOCK_MAP_ACT_HIGH			ADDRESS_BLOCK_MAP_ACT_LOW+MAP_MAXIMUM_WAYPOINT+1
#define ADDRESS_BLOCK_MAP_UNTIL_CASE_L		ADDRESS_BLOCK_MAP_ACT_HIGH+MAP_MAXIMUM_WAYPOINT+1
#define ADDRESS_BLOCK_MAP_UNTIL_CASE_H		ADDRESS_BLOCK_MAP_UNTIL_CASE_L+MAP_MAXIMUM_WAYPOINT+1

///Deprecated
//~ 
//~ #define WAYPOINTS					50
//~ #define MAP_SIZE					WAYPOINTS
//~ #define ADDRESS_BLOCK_MAP_MAZE_TOTAL	ADDRESS_BLOCK_CASE_V+CASE_SIZE+1
//~ #define ADDRESS_BLOCK_MAP_CASE_H	ADDRESS_BLOCK_MAP_MAZE_TOTAL+1							/**																												**/
//~ #define ADDRESS_BLOCK_MAP_CASE_L	ADDRESS_BLOCK_MAP_CASE_H+MAP_SIZE+1						/**																												**/
//~ #define ADDRESS_BLOCK_MAP_ACT_SPEED ADDRESS_BLOCK_MAP_CASE_L+MAP_SIZE+1						/**																												**/
//~ #define ADDRESS_BLOCK_MAP_ACT_KP	ADDRESS_BLOCK_MAP_ACT_SPEED+MAP_SIZE+1					/**																												**/
//~ #define ADDRESS_BLOCK_MAP_ACT_KD	ADDRESS_BLOCK_MAP_ACT_KP+MAP_SIZE+1						/**																												**/
//~ #define ADDRESS_BLOCK_MAP_ACT_TURN_CASE_A_UNTIL_A	ADDRESS_BLOCK_MAP_ACT_KD+MAP_SIZE+1 		//BIT CONFIG  [CASE_A][CASE_A][CASE_A]	[UNTIL_A][UNTIL_A][UNTIL_A]	[TURN][TURN]
//~ #define ADDRESS_BLOCK_MAP_UNTIL_H	ADDRESS_BLOCK_MAP_ACT_TURN_CASE_A_UNTIL_A+MAP_SIZE+1		/**	   bit7 [caseA s.kiri] [caseA s.tengah] [caseA s.kanan]	bit5										**/
//~ #define ADDRESS_BLOCK_MAP_UNTIL_L	ADDRESS_BLOCK_MAP_UNTIL_H+MAP_SIZE+1						/**				bit4 [untilA s.kiri] [untilA s.tengah] [untilA s.kanan]	bit2																									**/

//~ #define ADDRESS_BLOCK_ACTION			ADDRESS_BLOCK_CASE_V


#define ADDRESS_BLOCK_SENSOR_REF	ADDRESS_BLOCK_MAP_UNTIL_CASE_H+MAP_MAXIMUM_WAYPOINT+1
#define ADDRESS_BLOCK_DRIVE_SPEED	ADDRESS_BLOCK_SENSOR_REF+20
#define ADDRESS_BLOCK_DRIVE_KP		ADDRESS_BLOCK_DRIVE_SPEED+1
#define ADDRESS_BLOCK_DRIVE_KD		ADDRESS_BLOCK_DRIVE_KP+1

																							/**					bit1 [TURN][TURN] bit0																						**/
// 2 bit driver command: 10 forward, 00 right, 01 backward, 11 left
#define MAP_ACT_TURN_FORWARD		2 //00																	#define SENS_A_LEFT	2
#define MAP_ACT_TURN_BACKWARD		1 //01																	#define SENS_A_MID	1
#define MAP_ACT_TURN_LEFT			3 //10																	#define SENS_A_RIGHT 0
#define MAP_ACT_TURN_RIGHT			0 //11
//ALIASES
#define TURN_FORWARD 				2
#define TURN_BACKWARD 				1
#define TURN_LEFT 					3
#define TURN_RIGHT 					0
#define DIR_FORWARD 				2
#define DIR_BACKWARD 				1
#define DIR_LEFT 					3
#define DIR_RIGHT 					0
#define DRIVE_FORWARD 				2
#define DRIVE_BACKWARD 				1
#define DRIVE_LEFT					3
#define DRIVE_RIGHT					0

#define DELAY_300_MS				3



#define MAP_GET_ACT_DIRECTION			14
#define MAP_GET_ACT_PWM_RIGHT			11
#define MAP_GET_ACT_PWM_LEFT			8
#define MAP_GET_ACT_TIME_MS				5
#define MAP_GET_ACT_NEXT_RUN_SAMPLES	2
#define MAP_GET_ACT_NEXT_SENSOR_CONFIG	1
#define MAP_GET_ACT_NEXT_RUN_UNTIL		0

uint8_t MapGetAct(uint8_t act, uint8_t act_low, uint8_t act_high);
uint8_t MapGetActTranslate(uint8_t act, uint8_t act_low, uint8_t act_high);
void MapWriteTurn(uint8_t queue_num, uint8_t turn);
void MapWriteCaseA(uint8_t queue_num, uint8_t casea);
void MapWriteUntilA(uint8_t queue_num, uint8_t untila);
void MapWriteTCAUA(uint8_t queue_num, uint8_t tcaua);
uint8_t MapReadTCAUA(uint8_t queue_num);
uint8_t MapReadCaseA(uint8_t queue_num);
uint8_t MapReadUntilA(uint8_t queue_num);
uint8_t MapReadTurn(uint8_t queue_num);

uint8_t gMazeMapNum=0; ///POSISI ROBOT SUDAH DIMANA
uint8_t gMazeMapTot=10;///TOTAL MAPPING

uint8_t gInverted = 0;

#define OCR_LEFT	OCR1A
#define OCR_RIGHT	OCR1B

uint8_t Button0(void);
uint8_t Button1(void);
uint8_t Button2(void);
uint8_t Button3(void);
uint8_t ButtonEnter(void);
uint8_t ButtonBack(void);
uint8_t ButtonNext(void);
uint8_t ButtonPrev(void);
void ButtonWait(void);
uint8_t ButtonIsPressed(void);
uint8_t ButtonIsNotPressed(void);
uint8_t ButtonRead(void);
void Init(void);
void SaveCase(void);
void LoadCase(void);
void SetComplex(void);
void SetMinim(void);
void SetMinimInverse(void);<commit_msg>commented-out unused function and old mapping idea<commit_after>/* BISMILLAH																																											*/
///		<NAME>
///		<NAME>
																																														/*
 * made from scratch 
 * 30 OKTOBER 2011
 * Makin
 * 
 * ATMEGA 32:
 * 	EEPROM 1024 Bytes
 * 	SRAM	  2048 Bytes
 * 
 * ADC sensor dpn 34567 ~67 adc, 345 sel
 */

//~ #define F_CPU 12000000
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>
#include <avr/pgmspace.h>
#include "lcd_lib.h"
#include <avr/eeprom.h>
#include "makin.h"

#define elif else if


///~ #define EepromWrite(_BLOCK,_VALUE)	eeprom_write_byte((uint8_t*)(_BLOCK),_VALUE) 
///Use update instead of write
#define EepromWrite(_BLOCK,_VALUE)	eeprom_update_byte((uint8_t*)(_BLOCK),_VALUE)
#define EepromRead(_BLOCK)	eeprom_read_byte((uint8_t*)(_BLOCK))


#define A_CUSTOM_COUNT 1


///Sensor case
#define ADDRESS_BLOCK_CASE_N		2
#define CASE_SIZE					40
#define ADDRESS_BLOCK_CASE_H		ADDRESS_BLOCK_CASE_N+1
#define ADDRESS_BLOCK_CASE_L		ADDRESS_BLOCK_CASE_H+CASE_SIZE+1
#define ADDRESS_BLOCK_CASE_V		ADDRESS_BLOCK_CASE_L+CASE_SIZE+1

#define ADDRESS_BLOCK_MAP_WAYPOINTS_NUM		ADDRESS_BLOCK_CASE_V+CASE_SIZE+1
#define MAP_MAXIMUM_WAYPOINT				200
#define ADDRESS_BLOCK_MAP_ACT_LOW			ADDRESS_BLOCK_MAP_WAYPOINTS_NUM+1
#define ADDRESS_BLOCK_MAP_ACT_HIGH			ADDRESS_BLOCK_MAP_ACT_LOW+MAP_MAXIMUM_WAYPOINT+1
#define ADDRESS_BLOCK_MAP_UNTIL_CASE_L		ADDRESS_BLOCK_MAP_ACT_HIGH+MAP_MAXIMUM_WAYPOINT+1
#define ADDRESS_BLOCK_MAP_UNTIL_CASE_H		ADDRESS_BLOCK_MAP_UNTIL_CASE_L+MAP_MAXIMUM_WAYPOINT+1

///Deprecated
//~ 
//~ #define WAYPOINTS					50
//~ #define MAP_SIZE					WAYPOINTS
//~ #define ADDRESS_BLOCK_MAP_MAZE_TOTAL	ADDRESS_BLOCK_CASE_V+CASE_SIZE+1
//~ #define ADDRESS_BLOCK_MAP_CASE_H	ADDRESS_BLOCK_MAP_MAZE_TOTAL+1							/**																												**/
//~ #define ADDRESS_BLOCK_MAP_CASE_L	ADDRESS_BLOCK_MAP_CASE_H+MAP_SIZE+1						/**																												**/
//~ #define ADDRESS_BLOCK_MAP_ACT_SPEED ADDRESS_BLOCK_MAP_CASE_L+MAP_SIZE+1						/**																												**/
//~ #define ADDRESS_BLOCK_MAP_ACT_KP	ADDRESS_BLOCK_MAP_ACT_SPEED+MAP_SIZE+1					/**																												**/
//~ #define ADDRESS_BLOCK_MAP_ACT_KD	ADDRESS_BLOCK_MAP_ACT_KP+MAP_SIZE+1						/**																												**/
//~ #define ADDRESS_BLOCK_MAP_ACT_TURN_CASE_A_UNTIL_A	ADDRESS_BLOCK_MAP_ACT_KD+MAP_SIZE+1 		//BIT CONFIG  [CASE_A][CASE_A][CASE_A]	[UNTIL_A][UNTIL_A][UNTIL_A]	[TURN][TURN]
//~ #define ADDRESS_BLOCK_MAP_UNTIL_H	ADDRESS_BLOCK_MAP_ACT_TURN_CASE_A_UNTIL_A+MAP_SIZE+1		/**	   bit7 [caseA s.kiri] [caseA s.tengah] [caseA s.kanan]	bit5										**/
//~ #define ADDRESS_BLOCK_MAP_UNTIL_L	ADDRESS_BLOCK_MAP_UNTIL_H+MAP_SIZE+1						/**				bit4 [untilA s.kiri] [untilA s.tengah] [untilA s.kanan]	bit2																									**/

//~ #define ADDRESS_BLOCK_ACTION			ADDRESS_BLOCK_CASE_V


#define ADDRESS_BLOCK_SENSOR_REF	ADDRESS_BLOCK_MAP_UNTIL_CASE_H+MAP_MAXIMUM_WAYPOINT+1
#define ADDRESS_BLOCK_DRIVE_SPEED	ADDRESS_BLOCK_SENSOR_REF+20
#define ADDRESS_BLOCK_DRIVE_KP		ADDRESS_BLOCK_DRIVE_SPEED+1
#define ADDRESS_BLOCK_DRIVE_KD		ADDRESS_BLOCK_DRIVE_KP+1

																							/**					bit1 [TURN][TURN] bit0																						**/
// 2 bit driver command: 10 forward, 00 right, 01 backward, 11 left
#define MAP_ACT_TURN_FORWARD		2 //00																	#define SENS_A_LEFT	2
#define MAP_ACT_TURN_BACKWARD		1 //01																	#define SENS_A_MID	1
#define MAP_ACT_TURN_LEFT			3 //10																	#define SENS_A_RIGHT 0
#define MAP_ACT_TURN_RIGHT			0 //11
//ALIASES
#define TURN_FORWARD 				2
#define TURN_BACKWARD 				1
#define TURN_LEFT 					3
#define TURN_RIGHT 					0
#define DIR_FORWARD 				2
#define DIR_BACKWARD 				1
#define DIR_LEFT 					3
#define DIR_RIGHT 					0
#define DRIVE_FORWARD 				2
#define DRIVE_BACKWARD 				1
#define DRIVE_LEFT					3
#define DRIVE_RIGHT					0

#define DELAY_300_MS				3



#define MAP_GET_ACT_DIRECTION			14
#define MAP_GET_ACT_PWM_RIGHT			11
#define MAP_GET_ACT_PWM_LEFT			8
#define MAP_GET_ACT_TIME_MS				5
#define MAP_GET_ACT_NEXT_RUN_SAMPLES	2
#define MAP_GET_ACT_NEXT_SENSOR_CONFIG	1
#define MAP_GET_ACT_NEXT_RUN_UNTIL		0

uint8_t MapGetAct(uint8_t act, uint8_t act_low, uint8_t act_high);
uint8_t MapGetActTranslate(uint8_t act, uint8_t act_low, uint8_t act_high);
/** //deprecated, while the idea kept for a while
void MapWriteTurn(uint8_t queue_num, uint8_t turn);
void MapWriteCaseA(uint8_t queue_num, uint8_t casea);
void MapWriteUntilA(uint8_t queue_num, uint8_t untila);
void MapWriteTCAUA(uint8_t queue_num, uint8_t tcaua);
uint8_t MapReadTCAUA(uint8_t queue_num);
uint8_t MapReadCaseA(uint8_t queue_num);
uint8_t MapReadUntilA(uint8_t queue_num);
uint8_t MapReadTurn(uint8_t queue_num);

uint8_t gMazeMapNum=0; ///POSISI ROBOT SUDAH DIMANA
uint8_t gMazeMapTot=10;///TOTAL MAPPING
**/
uint8_t gInverted = 0;

#define OCR_LEFT	OCR1A
#define OCR_RIGHT	OCR1B

uint8_t Button0(void);
uint8_t Button1(void);
uint8_t Button2(void);
uint8_t Button3(void);
uint8_t ButtonEnter(void);
uint8_t ButtonBack(void);
uint8_t ButtonNext(void);
uint8_t ButtonPrev(void);
void ButtonWait(void);
uint8_t ButtonIsPressed(void);
uint8_t ButtonIsNotPressed(void);
uint8_t ButtonRead(void);
void Init(void);
void SaveCase(void);
void LoadCase(void);
void SetComplex(void);
void SetMinim(void);
void SetMinimInverse(void);
{'fraction_non_alphanumeric': 0.08753315649867374, 'fraction_numerical': 0.03239863584691171, 'mean_word_length': 3.944730679156909, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2284174', 'n_tokens_mistral': 4689, 'n_tokens_neox': 4336, 'n_words': 755}