Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
PHONY := all package clean | ||
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) | ||
|
||
CC := arm-vita-eabi-gcc | ||
CXX := arm-vita-eabi-g++ | ||
STRIP := arm-vita-eabi-strip | ||
|
||
PROJECT_TITLE := Power Sample | ||
PROJECT_TITLEID := VSDK00016 | ||
|
||
PROJECT := vita_sample | ||
CXXFLAGS += -std=c++11 -I../common | ||
CFLAGS += -I../common | ||
|
||
LIBS := -lSceCtrl_stub -lSceDisplay_stub -lSceKernel_stub -lScePower_stub | ||
|
||
SRC_C :=$(call rwildcard, src/, *.c) | ||
SRC_CPP :=$(call rwildcard, src/, *.cpp) | ||
|
||
OBJ_DIRS := $(addprefix out/, $(dir $(SRC_C:src/%.c=%.o))) $(addprefix out/, $(dir $(SRC_CPP:src/%.cpp=%.o))) | ||
OBJS := $(addprefix out/, $(SRC_C:src/%.c=%.o)) $(addprefix out/, $(SRC_CPP:src/%.cpp=%.o)) | ||
|
||
|
||
all: package | ||
|
||
package: $(PROJECT).vpk | ||
|
||
$(PROJECT).vpk: eboot.bin param.sfo | ||
vita-pack-vpk -s param.sfo -b eboot.bin $(PROJECT).vpk | ||
|
||
eboot.bin: $(PROJECT).velf | ||
vita-make-fself $(PROJECT).velf eboot.bin | ||
|
||
param.sfo: | ||
vita-mksfoex -s TITLE_ID="$(PROJECT_TITLEID)" "$(PROJECT_TITLE)" param.sfo | ||
|
||
$(PROJECT).velf: $(PROJECT).elf | ||
$(STRIP) -g $< | ||
vita-elf-create $< $@ | ||
|
||
$(PROJECT).elf: $(OBJS) | ||
$(CXX) -Wl,-q $(CFLAGS) -o $@ $^ $(LIBS) | ||
|
||
$(OBJ_DIRS): | ||
mkdir -p $@ | ||
|
||
out/%.o : src/%.cpp | $(OBJ_DIRS) | ||
arm-vita-eabi-g++ -c $(CXXFLAGS) -o $@ $< | ||
|
||
out/%.o : src/%.c | $(OBJ_DIRS) | ||
arm-vita-eabi-g++ -c $(CFLAGS) -o $@ $< | ||
|
||
clean: | ||
rm -f $(PROJECT).velf $(PROJECT).elf $(PROJECT).vpk param.sfo eboot.bin $(OBJS) | ||
rm -r $(abspath $(OBJ_DIRS)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <psp2/ctrl.h> | ||
#include <psp2/kernel/processmgr.h> | ||
#include <psp2/power.h> | ||
|
||
#include "debugScreen.h" | ||
|
||
/* Define printf, just to make typing easier */ | ||
#define printf psvDebugScreenPrintf | ||
|
||
/* main routine */ | ||
int main(int argc, char *argv[]) | ||
{ | ||
SceCtrlData pad; | ||
int i = 0; | ||
int batteryLifeTime = 0; | ||
|
||
psvDebugScreenInit(); | ||
|
||
printf("PS Vita Power Sample v0.1\n\n"); | ||
|
||
printf("External power: %s\n", scePowerIsPowerOnline()? "yes" : "no "); | ||
printf("Low charge: %s\n", scePowerIsLowBattery()? "yes" : "no "); | ||
printf("Charging: %s\n", scePowerIsBatteryCharging()? "yes" : "no "); | ||
printf("Battery life percent: %d%%\n", scePowerGetBatteryLifePercent()); | ||
batteryLifeTime = scePowerGetBatteryLifeTime(); | ||
printf("Battery life time: (%02dh%02dm)\n", batteryLifeTime/60, batteryLifeTime-(batteryLifeTime/60*60)); | ||
printf("Clock frequency of the ARM: %d mHz\n", scePowerGetArmClockFrequency()); | ||
printf("Clock frequency of the BUS: %d mHz\n", scePowerGetBusClockFrequency()); | ||
printf("Clock frequency of the GPU: %d mHz\n", scePowerGetGpuClockFrequency()); | ||
|
||
printf("\n\nPress start to exit\n"); | ||
|
||
while (1) | ||
{ | ||
memset(&pad, 0, sizeof(pad)); | ||
sceCtrlPeekBufferPositive(0, &pad, 1); | ||
|
||
if (pad.buttons & SCE_CTRL_START) | ||
break; | ||
} | ||
|
||
sceKernelExitProcess(0); | ||
|
||
return 0; | ||
} |