flash 读写问题
本帖最后由 dody1209 于 2024-4-21 22:28 编辑local byte_addr = 0x00000000
--[[初始化函数
function on_init()
local read_data={} --定义读取的数组
if read_flash(0,1)~=nil then --判断flash是否被写过
read_data=read_flash(byte_addr,1) --读取flash的数值
set_value(0,3,read_data) --初始化到文本控件
--set_value(0,3,read_data) --这里这个值是我用来做测试的,也就是通过输入,这里的参数也会显示为我输入的值
else
set_value(0,3,123)
end
end--]]
--用户通过触摸修改控件后,执行此回调函数。
function on_control_notify(screen,control,value)
if screen == 0
then
if control == 4 and value == 0
then
local save= {} --定义保存的数组
save=get_value(0,2) --对数组的第一个字节赋值
flush_flash()
write_flash(byte_addr,save) --对flash进行数组的写操作
elseif control == 6 and value == 0
then
local read_data= {}
read_data=read_flash(byte_addr,1) --读取flash的数值
set_value(0,3,read_data)
end
end
发现按存储和读取按键时,并没有对flash进行操作,是缺少什么设置吗?我看了大彩的例程“Lua - APIFlash读写”,没发现有什么不同的设置。
页:
[1]