2012-03-09 01:44:22 +00:00
|
|
|
--[[
|
|
|
|
Copyright (C) 2011 Hans-Werner Hilse <hilse@web.de>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
]]--
|
|
|
|
|
|
|
|
--[[
|
|
|
|
Codes for rotation modes:
|
|
|
|
|
|
|
|
1 for no rotation,
|
|
|
|
2 for landscape with bottom on the right side of screen, etc.
|
|
|
|
|
2012-03-09 10:45:55 +00:00
|
|
|
2
|
2012-03-09 01:44:22 +00:00
|
|
|
+--------------+
|
|
|
|
| +----------+ |
|
|
|
|
| | | |
|
|
|
|
| | Freedom! | |
|
|
|
|
| | | |
|
|
|
|
| | | |
|
2012-03-09 10:34:56 +00:00
|
|
|
3 | | | | 1
|
2012-03-09 01:44:22 +00:00
|
|
|
| | | |
|
|
|
|
| | | |
|
|
|
|
| +----------+ |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
+--------------+
|
2012-03-09 10:45:55 +00:00
|
|
|
0
|
2012-03-09 01:44:22 +00:00
|
|
|
--]]
|
|
|
|
|
|
|
|
|
|
|
|
Screen = {
|
2012-03-09 10:34:56 +00:00
|
|
|
cur_rotation_mode = 0,
|
2012-03-09 01:44:22 +00:00
|
|
|
}
|
|
|
|
|
2012-03-10 08:41:23 +00:00
|
|
|
-- @orien: 1 for clockwise rotate, -1 for anti-clockwise
|
|
|
|
-- Remember to reread screen resolution after this function call
|
2012-03-09 01:44:22 +00:00
|
|
|
function Screen:screenRotate(orien)
|
|
|
|
if orien == "clockwise" then
|
|
|
|
orien = -1
|
2012-03-09 10:34:56 +00:00
|
|
|
elseif orien == "anticlockwise" then
|
|
|
|
orien = 1
|
2012-03-09 01:44:22 +00:00
|
|
|
else
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-03-09 10:34:56 +00:00
|
|
|
self.cur_rotation_mode = (self.cur_rotation_mode + orien) % 4
|
2012-03-09 10:45:55 +00:00
|
|
|
-- you have to reopen framebuffer after rotate
|
2012-03-09 10:34:56 +00:00
|
|
|
fb:setOrientation(self.cur_rotation_mode)
|
2012-03-09 01:44:22 +00:00
|
|
|
fb:close()
|
|
|
|
fb = einkfb.open("/dev/fb0")
|
|
|
|
end
|
|
|
|
|
|
|
|
function Screen:updateRotationMode()
|
2012-03-09 10:34:56 +00:00
|
|
|
if KEY_FW_DOWN == 116 then -- in EMU mode always set to 0
|
|
|
|
self.cur_rotation_mode = 0
|
2012-03-09 01:44:22 +00:00
|
|
|
else
|
|
|
|
orie_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_orientation", "r"))
|
|
|
|
updown_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_upside_down", "r"))
|
2012-03-09 10:34:56 +00:00
|
|
|
self.cur_rotation_mode = orie_fd:read() + (updown_fd:read() * 2)
|
2012-03-09 01:44:22 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|