<commit_before>#pragma once
//=====================================================================//
/*!	@file
	@brief	ST7567 LCD ドライバー
	@author	平松邦仁 (<EMAIL>)
*/
//=====================================================================//
#include <cstdint>
#include "common/spi_io.hpp"

namespace device {

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	/*!
		@brief  LCD テンプレートクラス @n
				PORT ポート指定クラス： @n
				class port { @n
				public: @n
					void scl_out(bool val) const { } @n
					void sda_out(bool val) const { } @n
				};
		@param[in]	PORT	SPI ポート定義クラス
		@param[in]	CTRL	SPI コントロール定義クラス
	*/
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	template <class PORT, class CTRL>
	class lcd_io {

		spi_io<PORT>	spi_;
		CTRL			ctrl_;

	public:
		//-----------------------------------------------------------------//
		/*!
			@brief  開始
		*/
		//-----------------------------------------------------------------//
		void start() const {
			// 100ms setup...
			for(uint8_t i = 0; i < 10; ++i) {
				utils::delay::micro_second(10000);
			}

			ctrl_.a0_out(0);
			ctrl_.lcd_sel(0);	// device enable

			spi_.write(0xae);	// display off
			spi_.write(0x40);	// display start line of 0
			spi_.write(0xa1);	// ADC set to reverse
			spi_.write(0xc0);	// common output mode: set scan direction normal operation
			spi_.write(0xa6);	// display normal (none reverse)
			spi_.write(0xa2);	// select bias b0:0=1/9, b0:1=1/7
			spi_.write(0x2f);	// all power control circuits on

			spi_.write(0xf8);	// set booster ratio to
			spi_.write(0x00);	// 4x

			spi_.write(0x27);	// set V0 voltage resistor ratio to large

			spi_.write(0x81);	// set contrast
			spi_.write(0x0);	// contrast value, EA default: 0x016

			spi_.write(0xac);	// indicator
			spi_.write(0x00);	// disable

			spi_.write(0xa4);	// all pixel on disable
			spi_.write(0xaf);	// display on

			for(uint8_t i = 0; i < 5; ++i) {
				utils::delay::micro_second(10000);
			}

			ctrl_.lcd_sel(1);	// device disable
		}


		//-----------------------------------------------------------------//
		/*!
			@brief  コピー
			@param[in]	p	フレームバッファソース
		*/
		//-----------------------------------------------------------------//
		void copy(const uint8_t* p) const {
			ctrl_.lcd_sel(0);
			for(uint8_t page = 0; page < 4; ++page) {
				ctrl_.a0_out(0);
				spi_.write(0xb0 + page);
				spi_.write(0x10);  // column upper
				spi_.write(0x04);  // column lower
				ctrl_.a0_out(1);
				for(uint8_t i = 0; i < 128; ++i) {
					spi_.write(*p);
					++p;
				}
			}
			ctrl_.lcd_sel(1);
		}

	};
}<commit_msg>update port define<commit_after>#pragma once
//=====================================================================//
/*!	@file
	@brief	ST7567 LCD ドライバー
	@author	平松邦仁 (<EMAIL>)
*/
//=====================================================================//
#include <cstdint>
#include "common/spi_io.hpp"

namespace device {

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	/*!
		@brief  LCD テンプレートクラス
		@param[in]	SPI		SPI ポート定義クラス
		@param[in]	SEL		LCD 選択
		@param[in]	CMD		コマンド選択（CMD:L、DATA:H）
	*/
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	template <class SPI, class SEL, class CMD>
	class lcd_io {

		SPI&	spi_;

	public:
		//-----------------------------------------------------------------//
		/*!
			@brief  コンストラクター
		*/
		//-----------------------------------------------------------------//
		lcd_io(SPI& spi) : spi_(spi) { }


		//-----------------------------------------------------------------//
		/*!
			@brief  開始
		*/
		//-----------------------------------------------------------------//
		void start() const {
			// 100ms setup...
			for(uint8_t i = 0; i < 10; ++i) {
				utils::delay::micro_second(10000);
			}

			CMD::P = 0;
			SEL::P = 0;	// device enable

			spi_.xchg(0xae);	// display off
			spi_.xchg(0x40);	// display start line of 0
			spi_.xchg(0xa1);	// ADC set to reverse
			spi_.xchg(0xc0);	// common output mode: set scan direction normal operation
			spi_.xchg(0xa6);	// display normal (none reverse)
			spi_.xchg(0xa2);	// select bias b0:0=1/9, b0:1=1/7
			spi_.xchg(0x2f);	// all power control circuits on

			spi_.xchg(0xf8);	// set booster ratio to
			spi_.xchg(0x00);	// 4x

			spi_.xchg(0x27);	// set V0 voltage resistor ratio to large

			spi_.xchg(0x81);	// set contrast
			spi_.xchg(0x0);	// contrast value, EA default: 0x016

			spi_.xchg(0xac);	// indicator
			spi_.xchg(0x00);	// disable

			spi_.xchg(0xa4);	// all pixel on disable
			spi_.xchg(0xaf);	// display on

			for(uint8_t i = 0; i < 5; ++i) {
				utils::delay::micro_second(10000);
			}

			SEL::P = 1;	// device disable
		}


		//-----------------------------------------------------------------//
		/*!
			@brief  コピー
			@param[in]	p	フレームバッファソース
		*/
		//-----------------------------------------------------------------//
		void copy(const uint8_t* p) const {
			SEL::P = 0;
			for(uint8_t page = 0; page < 4; ++page) {
				CMD::P = 0;
				uint8_t tmp[3];
				tmp[0] = 0xb0 + page;
				tmp[1] = 0x10;
				tmp[2] = 0x04;
				spi_.send(tmp, 3);
				CMD::P = 1;
				spi_.send(p, 128);
				p += 128;
			}
			SEL::P = 1;
		}

	};
}
{'fraction_non_alphanumeric': 0.36527751104282696, 'fraction_numerical': 0.039178029575571344, 'mean_word_length': 1.7969924812030076, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 10, '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': '461225', 'n_tokens_mistral': 2270, 'n_tokens_neox': 1855, 'n_words': 391}