/******************** F r i e n d s h i p E n d e r ********************
 * 本程序隶属于 Readguy 开源项目, 请尊重开源开发者, 也就是我FriendshipEnder.
 * 如果有条件请到 extra/artset/reward 中扫描打赏,否则请在 Bilibili 上支持我.
 * 项目交流QQ群: 926824162 (萌新可以进来问问题的哟)
 * 郑重声明: 未经授权还请不要商用本开源项目编译出的程序.
 * @file guy_154c.cpp
 * @author FriendshipEnder (f_ender@163.com), Bilibili: FriendshipEnder
 * @brief 1.54英寸墨水屏 驱动库函数
 * @version 1.0
 * @date 2023-11-11

 * @attention
 * Copyright (c) 2022-2023 FriendshipEnder
 * 
 * Apache License, Version 2.0
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <stdlib.h>
#include "guy_154C.h"
#ifdef READGUY_DEV_154C
namespace guydev_154C{
//以下代码均为我 FriendshipEnder 原创, 呵呵哒~~

void drv::drv_init(){ //初始化屏幕
  //add driver code...
}
void drv::drv_fullpart(bool part){ //初始化慢刷功能
  if(lastRefresh) return;
  //add driver code...
}
void drv::drv_setDepth(uint8_t i){
  epdFull=0; iLut = i?(i>15?15:i):15;  //如果需要, 改成自己的代码
}
void drv::drv_dispWriter(std::function<uint8_t(int)> f,uint8_t m){ //单色刷新
  if(m&1){//stage 1
    if(lastRefresh) drv_dispWriter(f,2);
    //add driver code...
  }
  if(m&2){//stage 2
    uint32_t ms=millis()-lastRefresh;
    uint32_t u=epdFull?slowRefTime:fastRefTime;  //全刷:局刷 busy时间
    if(ms<u) guy_epdBusy(u-ms);   //对于busy电平为低电平忙碌,高电平正常的屏幕则改为ms-u
    lastRefresh=0;
    //add driver code...
  }
}
void drv::drv_sleep() { //开始屏幕睡眠
  if(RST_PIN>=0){ //RST_PIN<0 无法唤醒
    //add driver code...
  }
  epd_PowerOn = 0;
  epdFull = 1; //强制设置为慢刷新模式
}
}
#endif /* END OF FILE. ReadGuy project.
Copyright (C) 2023 FriendshipEnder. */


