/*
* Copyright 2021-2022 Ou Jianbo 59935554@qq.com
*
* 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.
*
* additional license
* If you use this software to write secondary development type products,
* must be released under GPL compatible free software license or commercial
* license.
*/
#include "LL_General.h"
//#define STB_IMAGE_IMPLEMENTATION
//#include "stb_image.h"
#include "LL_Linked_List.h"
#include "LL_Window.h"
#include "LL_Background.h"
#include "LL_Button.h"
#include "LL_Text.h"
#include "LL_LineEdit.h"
uint8_t llGetUtf8Len(uint8_t *utf8)
{
uint8_t nBytes = 0;
if ((*utf8 & 0x80) == 0)
{
nBytes = 1;
}
else
{
if((*utf8 & 0x20) == 0)
{
nBytes = 2;
}
else
{
if((*utf8 & 0x10) == 0)
{
nBytes = 3;
}
else
{
nBytes = 0;
}
}
}
return nBytes;
}
uint8_t llUtf8ToUnicode(uint8_t* unicode, uint8_t *utf8)
{
uint8_t nBytes = 0;
if ((*utf8 & 0x80) == 0)
{
nBytes = 1;
unicode[0] = *utf8;
}
else
{
if((*utf8 & 0x20) == 0)
{
nBytes = 2;
unicode[0] = (utf8[0] & 0x1f)>> 2;
unicode[1] = (utf8[0] & 0x3)<<6 | (utf8[1] & 0x3F);
}
else
{
if((*utf8 & 0x10) == 0)
{
nBytes = 3;
unicode[0] = ((utf8[0] & 0x0f) <<4) + ((utf8[1] & 0x3c) >>2);
unicode[1] = ((utf8[1] & 0x03) <<6) + (utf8[2] & 0x3f);
}
else
{
// debug("ERROR: utf-8 to unicode\n");
nBytes = 0;
unicode[0] = '?';
}
}
}
return nBytes;
}
/*******************************************************************************
* @name :llStringCompare
* @brief :比较两个字符串是否相同
* @param :str1 str2
* @return :bool
* @version :V0.1
* @author :
* @date :2018.5.10
* @details :比较字符串和长度是否都相同
*******************************************************************************/
bool llStringCompare(uint8_t* str1,uint8_t* str2)
{
uint32_t len1,len2;
len1=strlen((char*)str1);
len2=strlen((char*)str2);
if(len1==len2)
{
if(memcmp(str1,str2,len1)==0)
{
return true;
}
}
return false;
}
uint8_t* llStrcat(uint8_t* str1,uint8_t* str2)
{
uint8_t *outString;
outString=(uint8_t *)llMalloc(strlen((const char*)str1)+strlen((const char*)str2));
if(outString)
{
strcpy((char*)outString,(const char*)str1);
strcat((char*)outString,(const char*)str2);
}
return outString;
}
/**
* @brief 判断两个矩形是否重叠
* @param rc1 第一个矩阵的位置
* @param rc2 第二个矩阵的位置
* @return 两个矩阵是否重叠(边沿重叠,也认为是重叠)
*/
bool llRectIsOverlap(llGeometry rc1, llGeometry rc2)
{
if((rc1.x + rc1.width-1)>=rc2.x &&
(rc2.x + rc2.width-1)>=rc1.x &&
(rc1.y + rc1.height-1)>=rc2.y &&
(rc2.y + rc2.height-1)>=rc1.y )
{
return true;
}
return false;
}
/**
* @brief 判断一个矩形是否在另一个矩形内
* @param bigRect 大矩阵的位置
* @param smallRect 小矩阵的位置
* @return 小矩阵是否在大矩形内(包括边沿重叠)
*/
bool llRectIsFullIn(llGeometry bigRect, llGeometry smallRect)
{
if((smallRect.x>=bigRect.x) &&
(smallRect.y>=bigRect.y) &&
((smallRect.x+smallRect.width-1)<=(bigRect.x+bigRect.width-1)) &&
((smallRect.y+smallRect.height-1)<=(bigRect.y+bigRect.height-1)) )
{
return true;
}
return false;
}
bool llPointInRect(llPoint point, llGeometry rc)
{
if((point.x>=rc.x)&&(point.x<=(rc.x+rc.width-1))&&(point.y>=rc.y)&&(point.y<=(rc.y+rc.height-1)))
{
return true;
}
return false;
}
/***************************************************************************//**
* @fn bool llRectIntersect(const llGeometry rect1, const llGeometry rect2,llGeometry * outRect)
* @brief 两个矩形的相交区域
* @param rect1 矩形1
* rect2 矩形2
* outRect 返回矩形
* @return bool 是否有相交
* @version V0.1
* @date 2020-11-04
* @details
******************************************************************************/
bool llRectIntersect(const llGeometry rect1, const llGeometry rect2,llGeometry * outRect)
{
int16_t outX2,outY2;
/* Get the smaller area from 'a1_p' and 'a2_p' */
outRect->x = MAX(rect1.x, rect2.x);
outRect->y = MAX(rect1.y, rect2.y);
outX2 = MIN(rect1.x+rect1.width-1, rect2.x+rect2.width-1);
outY2 = MIN(rect1.y+rect1.height-1, rect2.y+rect2.height-1);
/*If x1 or y1 greater then x2 or y2 then the areas union is empty*/
bool union_ok = true;
if((outRect->x > outX2) || (outRect->y > outY2))
{
union_ok = false;
}
outRect->width=MAX(outX2,outRect->x)-MIN(outX2,outRect->x)+1;
outRect->height=MAX(outY2,outRect->y)-MIN(outY2,outRect->y)+1;
return union_ok;
}
void llFillLineMultipleTransparent5515Colors(int16_t x0,int16_t x1,int16_t y,llColor *color)
{
int16_t startX,endX;
int16_t i;
llColor *pos;
bool isWait=true;
for(i=x0; i<=x1; i++)
{
if(isWait)
{
if((((*color>>5)&1)!=0)&&(*color!=0x20))
{
startX=i;
pos=color;
isWait=false;
}
}
else
{
if(((*color>>5)&1)==0)
{
endX=i-1;
isWait=true;
llFillMultipleColors(startX,y,endX,y,pos);
}
}
color++;
}
if(isWait==false)
{
llFillMultipleColors(startX,y,x1,y,pos);
}
}
void llFillMultipleTransparent5515Colors(int16_t x0,int16_t y0,int16_t x1,int16_t y1,llColor *color)
{
int16_t y;
for(y = y0; y <= y1; y++)
{
llFillLineMultipleTransparent5515Colors(x0,x1,y,color);
color=color+(x1-x0)+1;
}
}
uint8_t convertTypeBit[6]= {16,16,32,32,32,16};//数据占用多少位
llSize llGeneralGetImageSize(uint32_t imageAddr)
{
llSize retSize= {0};
imageHeaderTypedef imageHeader;
if(imageAddr!=IMAGE_NONE)
{
llReadExFlash(imageAddr,(uint8_t*)&imageHeader,16);
retSize.width=imageHeader.width;
retSize.height=imageHeader.height;
}
return retSize;
}
llGeometry llGeneralGetImageGeometry(int16_t x,int16_t y,uint32_t imageAddr)
{
llGeometry retGeometry= {0};
imageHeaderTypedef imageHeader;
if(imageAddr!=IMAGE_NONE)
{
llReadExFlash(imageAddr,(uint8_t*)&imageHeader,16);
retGeometry.x=x;
retGeometry.y=y;
retGeometry.width=imageHeader.width;
retGeometry.height=imageHeader.height;
}
return retGeometry;
}
uint32_t llGeneralGetParentOverlapColor(uint32_t parentAddr,llGeometry parentGepmetry,llPoint childPos,uint8_t parentConvertTypeBit)
{
int16_t x;
int16_t y;
uint32_t retAddr;
x=childPos.x-parentGepmetry.x;
y=childPos.y-parentGepmetry.y;
retAddr=parentAddr+(parentGepmetry.width*y+x)*(parentConvertTypeBit/8);//偏移*颜色字节数
return retAddr;
}
LL_WEAK llGeometry llGeneralImage
没有合适的资源?快使用搜索试试~ 我知道了~
玲珑GUI是高效的界面开发解决方案

共69个文件
h:34个
c:33个
gitignore:1个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
28 浏览量
2023-06-04
16:20:18
上传
评论
收藏 169KB ZIP 举报
温馨提示
玲珑GUI是高效的界面开发解决方案。代替串口屏、组态,降低产品成本,产品软硬件自主可控。配套界面开发软件,图形化编辑界面,生成C代码,直接和用户产品代码结合。配套下载升级软件和bootloader,解决产品升级功能和图片下载问题。
资源推荐
资源详情
资源评论













收起资源包目录









































































共 69 条
- 1
资源评论


Java程序员-张凯
- 粉丝: 1w+
- 资源: 3078
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
